From 3d7ab79d91aef87f4de2eea27d4149a49f25759b Mon Sep 17 00:00:00 2001 From: Michal Iskierko Date: Fri, 12 Jan 2024 12:15:48 +0100 Subject: [PATCH] fix: execute BeforeDispatch only once Issue #4557 --- protocol/common/message_sender.go | 2 -- protocol/messenger.go | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/protocol/common/message_sender.go b/protocol/common/message_sender.go index 75ca16beb..6787ad4e3 100644 --- a/protocol/common/message_sender.go +++ b/protocol/common/message_sender.go @@ -241,8 +241,6 @@ func (s *MessageSender) SendGroup( } } - rawMessage.BeforeDispatch = nil - // Send to each recipients for _, recipient := range recipients { _, err = s.sendPrivate(ctx, recipient, &rawMessage) diff --git a/protocol/messenger.go b/protocol/messenger.go index 60e581a8e..19fc500ba 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -2399,6 +2399,9 @@ func (m *Messenger) sendChatMessage(ctx context.Context, message *common.Message return err } + // ensure that the message is saved only once + rawMessage.BeforeDispatch = nil + return m.persistence.SaveMessages([]*common.Message{message}) }