From f62aeab43d6eb1a9b5d81c21378a647e5adc0696 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Tue, 14 Nov 2023 09:53:37 -0500 Subject: [PATCH 1/2] Scope reply events to current portal & quoted user When bridging a Signal quote to a Matrix reply, consider events only from the portal in which the reply is being bridged when searching for the replied-to message. Also refuse to bridge the quote if there is no puppet for the Signal user who sent the message that was quoted. --- portal.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/portal.go b/portal.go index 7c467ea4..9c1f3bb1 100644 --- a/portal.go +++ b/portal.go @@ -963,7 +963,14 @@ func (portal *Portal) storeReactionInDB( func (portal *Portal) addSignalQuote(content *event.MessageEventContent, quote *signalmeow.IncomingSignalMessageQuoteData) { if quote != nil { - originalMessage := portal.bridge.DB.Message.FindBySenderAndTimestamp(quote.QuotedSender, quote.QuotedTimestamp) + puppet := portal.bridge.DB.Puppet.GetBySignalID(quote.QuotedSender) + if puppet == nil { + portal.log.Warn().Msgf("Couldn't find puppet for quoted sender %s", quote.QuotedSender) + return + } + originalMessage := portal.bridge.DB.Message.GetBySignalID( + puppet.SignalID, quote.QuotedTimestamp, portal.ChatID, portal.Receiver, + ) if originalMessage == nil { portal.log.Warn().Msgf("Couldn't find message with Signal ID %s/%d", quote.QuotedSender, quote.QuotedTimestamp) return From 60ffd1798d5725f389cba9b627b4805542c6dd42 Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Wed, 15 Nov 2023 11:30:48 -0500 Subject: [PATCH 2/2] Don't check quoted sender puppet --- portal.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/portal.go b/portal.go index 9c1f3bb1..ffe319c1 100644 --- a/portal.go +++ b/portal.go @@ -963,13 +963,8 @@ func (portal *Portal) storeReactionInDB( func (portal *Portal) addSignalQuote(content *event.MessageEventContent, quote *signalmeow.IncomingSignalMessageQuoteData) { if quote != nil { - puppet := portal.bridge.DB.Puppet.GetBySignalID(quote.QuotedSender) - if puppet == nil { - portal.log.Warn().Msgf("Couldn't find puppet for quoted sender %s", quote.QuotedSender) - return - } originalMessage := portal.bridge.DB.Message.GetBySignalID( - puppet.SignalID, quote.QuotedTimestamp, portal.ChatID, portal.Receiver, + quote.QuotedSender, quote.QuotedTimestamp, portal.ChatID, portal.Receiver, ) if originalMessage == nil { portal.log.Warn().Msgf("Couldn't find message with Signal ID %s/%d", quote.QuotedSender, quote.QuotedTimestamp)