From d4d02e8aba8c51cd77b1ad6dd53859b225929b72 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Tue, 10 May 2022 21:36:22 -0400 Subject: [PATCH] Add missing null check for inbound read receipts --- node/src/client.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/node/src/client.js b/node/src/client.js index 7849224..0189914 100644 --- a/node/src/client.js +++ b/node/src/client.js @@ -155,10 +155,19 @@ class UserClient { }) 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", { chatId: chat.logId, - senderId: reader.userId, + senderId: senderId, channelId: channel.channelId, channelType: channel.info.type, })