fix(backend/chat): 自分が作ったチャットルームに他人がメッセージを送ったときに未読にならない

Fix #15748
This commit is contained in:
syuilo 2025-04-03 11:15:16 +09:00
parent d07552424c
commit 1a3866c4f6
1 changed files with 8 additions and 2 deletions

View File

@ -211,9 +211,15 @@ export class ChatService {
file?: MiDriveFile | null;
uri?: string | null;
}): Promise<Packed<'ChatMessageLite'>> {
const memberships = await this.chatRoomMembershipsRepository.findBy({ roomId: toRoom.id });
const memberships = (await this.chatRoomMembershipsRepository.findBy({ roomId: toRoom.id })).map(m => ({
userId: m.userId,
isMuted: m.isMuted,
})).concat({ // ownerはmembershipレコードを作らないため
userId: toRoom.ownerId,
isMuted: false,
});
if (toRoom.ownerId !== fromUser.id && !memberships.some(member => member.userId === fromUser.id)) {
if (!memberships.some(member => member.userId === fromUser.id)) {
throw new Error('you are not a member of the room');
}