Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE/#433] 채팅방 읽음처리 재수정 #444

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions BE/src/chat/chat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export class ChatService {
.addSelect('chat.message', 'message')
.addSelect('chat.create_date', 'create_date')
.addSelect('chat.is_read', 'is_read')
.addSelect('chat.sender', 'sender')
.where(
'chat.id IN (SELECT MAX(chat.id) FROM chat GROUP BY chat.chat_room)',
);
Expand Down Expand Up @@ -113,7 +114,8 @@ export class ChatService {
'post.thumbnail as post_thumbnail',
'chat_info.create_date as last_chat_date',
'chat_info.message as last_chat',
'chat_info.is_read as all_read',
'chat_info.is_read as allread',
'chat_info.sender as sender',
])
.where('chat_room.writer = :userId', { userId: userId })
.orWhere('chat_room.user = :userId', { userId: userId })
Expand All @@ -131,13 +133,17 @@ export class ChatService {
? this.configService.get('DEFAULT_PROFILE_IMAGE')
: cur.user_profile_img;

if (!cur.all_read) {
chatListInfo.all_read = false;
cur.all_read = false;
if (cur.sender === userId) {
cur.allread = true;
} else {
cur.all_read = true;
if (cur.allread === 0) {
chatListInfo.all_read = false;
cur.allread = false;
} else {
cur.allread = true;
}
Comment on lines +139 to +144
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용자마다 채팅을 읽었는지 여부를 체크해줄 수 있어 좋은 것 같습니다

}

delete cur.sender;
acc.push(cur);
return acc;
}, []);
Expand Down
Loading