Skip to content

Commit

Permalink
fix: anon chat error
Browse files Browse the repository at this point in the history
  • Loading branch information
rjsdn0 committed Dec 2, 2024
1 parent 893fbe7 commit 01ee739
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/api/src/service/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const createMessage = async (
select: {
id: true,
displayName: true,
username: true,
},
},
type: true,
Expand All @@ -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(),
Expand Down Expand Up @@ -103,6 +103,7 @@ export const retrieve = async ({
if (message.type === "anonymous") {
displayMessage.user.id = 0;
displayMessage.user.displayName = "익명";
displayMessage.user.username = "익명";
}
return {
...displayMessage,
Expand Down
2 changes: 1 addition & 1 deletion packages/interface/src/user/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export type User = z.infer<typeof User>;
* some description about chat user schema goes here
*/
export const ChatUser = User.omit({
username: true,
// username: true,
});
export type ChatUser = z.infer<typeof ChatUser>;
5 changes: 4 additions & 1 deletion packages/web/src/services/chat/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
Expand Down

0 comments on commit 01ee739

Please sign in to comment.