From 946aa82038a38726f68a80032e8853e723487eca Mon Sep 17 00:00:00 2001 From: Farhad Jay Date: Sat, 23 Nov 2024 17:18:52 -0800 Subject: [PATCH] Fix invalid hash for messages with a user Only generating the hash for a message in the `ChatMessage` constructor doesn't consider the fact that a message's user is often set in a child class' contructor. A message's hash is derived from the user's ID, so its hash also needs to be regenerated in this circumstance. --- assets/chat/js/messages/ChatBroadcastMessage.js | 2 ++ assets/chat/js/messages/ChatDonationMessage.js | 2 ++ assets/chat/js/messages/ChatUserMessage.js | 2 ++ 3 files changed, 6 insertions(+) diff --git a/assets/chat/js/messages/ChatBroadcastMessage.js b/assets/chat/js/messages/ChatBroadcastMessage.js index a1c1ced8..a92a3ff2 100644 --- a/assets/chat/js/messages/ChatBroadcastMessage.js +++ b/assets/chat/js/messages/ChatBroadcastMessage.js @@ -7,6 +7,8 @@ export default class ChatBroadcastMessage extends ChatEventMessage { super(message, timestamp); this.type = MessageTypes.BROADCAST; this.user = user; + + this.generateMessageHash(); } buildUserTemplate(chat = null) { diff --git a/assets/chat/js/messages/ChatDonationMessage.js b/assets/chat/js/messages/ChatDonationMessage.js index 45148b0e..1a46d266 100644 --- a/assets/chat/js/messages/ChatDonationMessage.js +++ b/assets/chat/js/messages/ChatDonationMessage.js @@ -21,6 +21,8 @@ export default class ChatDonationMessage extends ChatEventMessage { this.type = MessageTypes.DONATION; this.amount = amount; this.expirationTimestamp = expirationTimestamp; + + this.generateMessageHash(); } html(chat = null) { diff --git a/assets/chat/js/messages/ChatUserMessage.js b/assets/chat/js/messages/ChatUserMessage.js index f391b3be..68c09c2d 100644 --- a/assets/chat/js/messages/ChatUserMessage.js +++ b/assets/chat/js/messages/ChatUserMessage.js @@ -28,6 +28,8 @@ export default class ChatUserMessage extends ChatMessage { this.title = ''; this.slashme = false; this.mentioned = []; + + this.generateMessageHash(); } html(chat = null) {