From 01ee739880c5da21b0f07bf37cac9b80452742cf Mon Sep 17 00:00:00 2001 From: rjsdn0 Date: Mon, 2 Dec 2024 23:12:53 +0900 Subject: [PATCH] fix: anon chat error --- packages/api/src/service/chat.ts | 5 +++-- packages/interface/src/user/common.ts | 2 +- packages/web/src/services/chat/common.ts | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/api/src/service/chat.ts b/packages/api/src/service/chat.ts index d29e2ec3..3c8c1685 100644 --- a/packages/api/src/service/chat.ts +++ b/packages/api/src/service/chat.ts @@ -22,6 +22,7 @@ export const createMessage = async ( select: { id: true, displayName: true, + username: true, }, }, type: true, @@ -33,10 +34,9 @@ export const createMessage = async ( if (type === "anonymous") { createdMessage.user.id = 0; createdMessage.user.displayName = "익명"; + createdMessage.user.username = "익명"; } - console.log(createdMessage); - return { ...createdMessage, createdAt: createdAt.toISOString(), @@ -103,6 +103,7 @@ export const retrieve = async ({ if (message.type === "anonymous") { displayMessage.user.id = 0; displayMessage.user.displayName = "익명"; + displayMessage.user.username = "익명"; } return { ...displayMessage, diff --git a/packages/interface/src/user/common.ts b/packages/interface/src/user/common.ts index 626a3ac6..8fa7b929 100644 --- a/packages/interface/src/user/common.ts +++ b/packages/interface/src/user/common.ts @@ -17,6 +17,6 @@ export type User = z.infer; * some description about chat user schema goes here */ export const ChatUser = User.omit({ - username: true, + // username: true, }); export type ChatUser = z.infer; diff --git a/packages/web/src/services/chat/common.ts b/packages/web/src/services/chat/common.ts index 34ca0e10..64ab170e 100644 --- a/packages/web/src/services/chat/common.ts +++ b/packages/web/src/services/chat/common.ts @@ -11,7 +11,10 @@ export const createDraftMessage = ( ): Message => ({ id: Math.max(...preExistingKeys, 0) + 1, type, - user: type === "anonymous" ? { id: 0, displayName: "익명" } : user, + user: + type === "anonymous" + ? { id: 0, displayName: "익명", username: "익명" } + : user, message, createdAt: new Date().toISOString(), });