From ba8236f06f07691f71ffff771b04e6de454d6fc8 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Mon, 23 Sep 2024 13:06:25 -0400 Subject: [PATCH] fix_: fix broken test by even more simplification --- protocol/message_persistence.go | 17 ----------------- protocol/persistence_test.go | 10 +++++----- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/protocol/message_persistence.go b/protocol/message_persistence.go index e07c817b610..89729ae931a 100644 --- a/protocol/message_persistence.go +++ b/protocol/message_persistence.go @@ -1580,11 +1580,6 @@ func (db sqlitePersistence) SaveMessages(messages []*common.Message) (err error) if err != nil { return } - // handle replies - err = db.findAndUpdateReplies(tx, msg.GetBridgeMessage().MessageID, msg.ID) - if err != nil { - return - } parentMessageID := msg.GetBridgeMessage().ParentMessageID if parentMessageID != "" { err = db.findAndUpdateRepliedTo(tx, parentMessageID, msg.ID) @@ -3044,18 +3039,6 @@ func (db sqlitePersistence) updateBridgeMessageContent(tx *sql.Tx, bridgeMessage return err } -// Finds if there are any messages that are replies to that message (in case replies were received earlier) -func (db sqlitePersistence) findAndUpdateReplies(tx *sql.Tx, bridgeMessageID string, statusMessageID string) error { - replyMessageIds, err := db.findStatusMessageIdsReplies(tx, bridgeMessageID) - if err != nil { - return err - } - if len(replyMessageIds) == 0 { - return nil - } - return db.updateStatusMessagesWithResponse(tx, replyMessageIds, statusMessageID) -} - func (db sqlitePersistence) findAndUpdateRepliedTo(tx *sql.Tx, discordParentMessageID string, statusMessageID string) error { return db.updateStatusMessagesWithResponse(tx, []string{statusMessageID}, discordParentMessageID) } diff --git a/protocol/persistence_test.go b/protocol/persistence_test.go index 3cb328f98af..a181b3ce943 100644 --- a/protocol/persistence_test.go +++ b/protocol/persistence_test.go @@ -1995,10 +1995,10 @@ func TestBridgeMessageReplies(t *testing.T) { err = insertMinimalBridgeMessage(p, "444", "4", "3") require.NoError(t, err) - // status message "222" should have reply_to = "111" + // status message "222" should have reply_to =" 1" because it's a discord message to another discord message responseTo, err := messageResponseTo(p, "222") require.NoError(t, err) - require.Equal(t, "111", responseTo) + require.Equal(t, "1", responseTo) responseTo, err = messageResponseTo(p, "111") require.NoError(t, err) @@ -2006,7 +2006,7 @@ func TestBridgeMessageReplies(t *testing.T) { responseTo, err = messageResponseTo(p, "444") require.NoError(t, err) - require.Equal(t, "", responseTo) + require.Equal(t, "3", responseTo) // receiving message for which "444" is replied to err = insertMinimalBridgeMessage(p, "333", "3", "") @@ -2016,10 +2016,10 @@ func TestBridgeMessageReplies(t *testing.T) { require.NoError(t, err) require.Equal(t, "", responseTo) - // now 444 is replied to 333 + // 444 is still replied to 3 responseTo, err = messageResponseTo(p, "444") require.NoError(t, err) - require.Equal(t, "333", responseTo) + require.Equal(t, "3", responseTo) } func createAndSaveMessage(p *sqlitePersistence, id string, from string, deleted bool, communityID string) error {