Repository: tuskyapp/Tusky (language: kotlin)

Issue:
Blocked users remain in notifications
### Detailed description

After blocking a user, notifications from or about that user should be removed or hidden.

### Steps to reproduce the problem

Actual behavior: 

* I received a notification of a new follower
* I examine their profile and determined it was a spam account
* I blocked the user (and reported them)
* The "new follower" notification still appears on the Notifications tab

Expected behavior: 

* The notification should be removed or hidden

Note: the notification is not visible through the octodon.social Mastodon web interface, so this could be a caching issue.

### Debug information

Tusky version 27.0 beta 1
Android 15 build AP4A.241205.013
Pixel 6 Pro


Discussion hints:
nan

Pull request: fix "delete all notifications by user" query
The brackets were at the wrong position and notification types are actually serialized differently.

Closes #4817 

Test command: ./gradlew :app:testBlueDebugUnitTest --tests "com.keylesspalace.tusky.db.dao.NotificationsDaoTest"

Fix patch:
diff --git a/app/src/main/java/com/keylesspalace/tusky/db/dao/NotificationsDao.kt b/app/src/main/java/com/keylesspalace/tusky/db/dao/NotificationsDao.kt
index e429dc20e3..9029ae7602 100644
--- a/app/src/main/java/com/keylesspalace/tusky/db/dao/NotificationsDao.kt
+++ b/app/src/main/java/com/keylesspalace/tusky/db/dao/NotificationsDao.kt
@@ -108,10 +108,10 @@ AND
      */
     @Query(
         """DELETE FROM NotificationEntity WHERE tuskyAccountId = :tuskyAccountId AND
-            statusId IN
-            (SELECT serverId FROM TimelineStatusEntity WHERE tuskyAccountId = :tuskyAccountId AND
-            (authorServerId == :userId OR accountId == :userId))
-            AND type != "admin.sign_up" AND type != "admin.report"
+            (accountId = :userId OR
+            statusId IN (SELECT serverId FROM TimelineStatusEntity WHERE tuskyAccountId = :tuskyAccountId AND authorServerId = :userId)
+            )
+            AND type != "SIGN_UP" AND type != "REPORT"
         """
     )
     abstract suspend fun removeAllByUser(tuskyAccountId: Long, userId: String)


Test patch:
diff --git a/app/src/test/java/com/keylesspalace/tusky/db/dao/NotificationsDaoTest.kt b/app/src/test/java/com/keylesspalace/tusky/db/dao/NotificationsDaoTest.kt
index 4a19aa0e0b..e3c14ad6a2 100644
--- a/app/src/test/java/com/keylesspalace/tusky/db/dao/NotificationsDaoTest.kt
+++ b/app/src/test/java/com/keylesspalace/tusky/db/dao/NotificationsDaoTest.kt
@@ -210,10 +210,11 @@ class NotificationsDaoTest {
             fakeNotification(type = Notification.Type.SIGN_UP, id = "4", account = fakeAccount(id = "1"), status = null, report = fakeReport(id = "1", targetAccount = fakeAccount(id = "4"))),
             // will not be removed because it does not reference account 1
             fakeNotification(id = "5", account = fakeAccount(id = "5"), status = fakeStatus(id = "5", authorServerId = "100")),
+            fakeNotification(type = Notification.Type.FOLLOW, id = "6", account = fakeAccount(id = "1"), status = null)
         )
 
         db.insert(notificationsAccount1, tuskyAccountId = 1)
-        db.insert(listOf(fakeNotification(id = "6")), tuskyAccountId = 2)
+        db.insert(listOf(fakeNotification(id = "2000")), tuskyAccountId = 2)
 
         notificationsDao.removeAllByUser(1, "1")
 
@@ -227,7 +228,7 @@ class NotificationsDaoTest {
         }
         cursor.close()
 
-        val expectedNotifications = listOf("3", "4", "5", "6")
+        val expectedNotifications = listOf("2000", "3", "4", "5")
 
         assertEquals(expectedNotifications, loadedNotifications)
     }