From 612d8918eab4a6e5c16ee751d4485d5570824f50 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Fri, 10 Dec 2021 14:34:16 +0000 Subject: [PATCH] Fix notification query --- VERSION | 2 +- protocol/activity_center_persistence.go | 2 +- protocol/persistence_test.go | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 4d47d83fb..fe37babed 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.92.3 +0.92.4 diff --git a/protocol/activity_center_persistence.go b/protocol/activity_center_persistence.go index 379254bc9..31b89a9f1 100644 --- a/protocol/activity_center_persistence.go +++ b/protocol/activity_center_persistence.go @@ -298,7 +298,7 @@ func (db sqlitePersistence) GetToProcessActivityCenterNotificationIds() ([][]byt } func (db sqlitePersistence) HasPendingNotificationsForChat(chatID string) (bool, error) { - rows, err := db.db.Query("SELECT 1 FROM activity_center_notifications a WHERE a.chat_id = ? NOT a.dismissed AND NOT a.accepted", chatID) + rows, err := db.db.Query("SELECT 1 FROM activity_center_notifications a WHERE a.chat_id = ? AND NOT a.dismissed AND NOT a.accepted", chatID) if err != nil { return false, err } diff --git a/protocol/persistence_test.go b/protocol/persistence_test.go index e38a80a88..69830d092 100644 --- a/protocol/persistence_test.go +++ b/protocol/persistence_test.go @@ -1303,3 +1303,13 @@ func TestSaveCommunityChat(t *testing.T) { require.NoError(t, err) require.Equal(t, chat, retrievedChat) } + +func TestHasPendingNotificationsForChatSanityCheck(t *testing.T) { + db, err := openTestDB() + require.NoError(t, err) + p := NewSQLitePersistence(db) + + result, err := p.HasPendingNotificationsForChat("test-chat-id") + require.NoError(t, err) + require.False(t, result) +}