Skip to content

Commit

Permalink
Merge pull request #309 from sparcs-kaist/dev
Browse files Browse the repository at this point in the history
Main branch update from Dev branch
  • Loading branch information
14KGun authored Jun 1, 2023
2 parents 984e1bb + 1312ab3 commit be5f3da
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/modules/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ const transformChatsForRoom = async (chats) => {
return chatsToSend;
};

// FCM 알림으로 보내는 content는 채팅 type에 따라 달라집니다.
// type이 text인 경우 `${nickname}: ${content}`를, 아닌 경우 `${nickname}`를 보냅니다.
/**
* FCM 알림으로 보내는 content는 채팅 type에 따라 달라집니다.
* 예를 들어, type이 "text"인 경우 `${nickname}: ${content}`를 보냅니다.
*/
const getMessageBody = (type, nickname, content) => {
// TODO: 채팅 메시지 유형에 따라 Body를 다르게 표시합니다.
if (type === "text") {
Expand All @@ -65,7 +67,7 @@ const getMessageBody = (type, nickname, content) => {
} else if (type === "s3img") {
// 채팅 유형이 이미지인 경우 본문은 "${nickname} 님이 이미지를 전송하였습니다"가 됩니다.
// TODO: 사용자 언어를 가져올 수 있으면 개선할 수 있다고 생각합니다.
const suffix = " 님이 이미지를 전송하였습니다.";
const suffix = " 님이 이미지를 전송하였습니다";
return `${nickname} ${suffix}`;
} else if (type === "in" || type === "out") {
// 채팅 메시지 type이 "in"이거나 "out"인 경우 본문은 "${nickname} 님이 입장하였습니다" 또는 "${nickname} 님이 퇴장하였습니다"가 됩니다.
Expand All @@ -81,6 +83,12 @@ const getMessageBody = (type, nickname, content) => {
? " 님이 결제를 완료하였습니다"
: " 님이 정산을 완료하였습니다";
return `${nickname} ${suffix}`;
} else if (type === "account") {
const suffix = " 님이 계좌번호를 전송하였습니다";
return `${nickname} ${suffix}`;
} else {
// 정의되지 않은 type의 경우에는 nickname만 반환합니다.
return nickname;
}
};

Expand Down

0 comments on commit be5f3da

Please sign in to comment.