diff --git a/server/services/broadcast.ts b/server/services/broadcast.ts index a583bb85d..ab3919f64 100644 --- a/server/services/broadcast.ts +++ b/server/services/broadcast.ts @@ -81,10 +81,10 @@ export default class BroadcastService { } gameConversationRead(game: Game, conversation: Conversation, readByPlayerId: DBObjectId) { - conversation.participants.forEach(p => this.playerServerSocketEmitter.emitGameConversationRead(p.toString(), { + this.playerServerSocketEmitter.emitGameConversationRead(readByPlayerId.toString(), { conversationId: conversation._id.toString(), readByPlayerId: readByPlayerId.toString() - })); + }); } gameConversationLeft(game: Game, conversation: Conversation, playerId: DBObjectId) { diff --git a/server/services/conversation.ts b/server/services/conversation.ts index 1e462fbea..efce758f6 100644 --- a/server/services/conversation.ts +++ b/server/services/conversation.ts @@ -197,6 +197,15 @@ export default class ConversationService extends EventEmitter { throw new ValidationError(`You are not participating in this conversation.`); } + convo.messages.forEach(cm => { + cm = cm; + cm.readBy = cm.readBy.filter(pid => pid.toString() === playerId.toString()); + }) + + if (convo.lastMessage != null) { + convo.lastMessage.readBy = convo.lastMessage.readBy.filter(pid => pid.toString() === playerId.toString()); + } + return convo; }