Add missing null check for inbound read receipts

This commit is contained in:
Andrew Ferrazzutti 2022-05-10 21:36:22 -04:00
parent fbd3d514e3
commit d4d02e8aba

View File

@ -155,10 +155,19 @@ class UserClient {
}) })
this.#talkClient.on("chat_read", (chat, channel, reader) => { this.#talkClient.on("chat_read", (chat, channel, reader) => {
this.log(`Chat ${chat.logId} read in channel ${channel.channelId} by ${reader.userId}`) let senderId
if (reader) {
senderId = reader.userId
} else if (channel.info.type == "MemoChat") {
senderId = channel.clientUser.userId
} else {
this.error(`Chat ${chat.logId} read in channel ${channel.channelId} by unknown reader (channel type: ${channel.info.type || "none"})`)
return
}
this.log(`Chat ${chat.logId} read in channel ${channel.channelId} by ${senderId}`)
this.write("chat_read", { this.write("chat_read", {
chatId: chat.logId, chatId: chat.logId,
senderId: reader.userId, senderId: senderId,
channelId: channel.channelId, channelId: channel.channelId,
channelType: channel.info.type, channelType: channel.info.type,
}) })