From 7e0822b62d70ed249da576feb7c5601c8d3b304e Mon Sep 17 00:00:00 2001 From: nebunez Date: Wed, 10 Mar 2021 14:07:47 -0500 Subject: [PATCH] fix mismatched message ids when client first sends a message This bug is caused by the message being sent to all clients before msg.SetDefaults() is called and the message is saved to the chat database. This causes connected clients to get a message id that is different from what exists in the database. This only affects clients using websockets that were connected when the message was sent and message visibility updated. Fixes https://github.com/owncast/owncast/issues/809 --- core/chat/server.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/chat/server.go b/core/chat/server.go index 5a32255da..0e8352d34 100644 --- a/core/chat/server.go +++ b/core/chat/server.go @@ -143,11 +143,13 @@ func (s *server) Listen() { msg.RenderAndSanitizeMessageBody() if !msg.Empty() { + // set defaults before sending msg to anywhere + msg.SetDefaults() + s.listener.MessageSent(msg) s.sendAll(msg) // Store in the message history - msg.SetDefaults() if !msg.Ephemeral { addMessage(msg) }