diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index d8d959ee5..6ee478939 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -395,7 +395,23 @@ public class NotificationService { count = getBacklogMessageCount(account); } - updateNotification(count > 0, conversations); + boolean shouldNotify = count > 0; + + if (shouldNotify) { + boolean allConversationsShouldBeThrottled = true; + for (String c : conversations) { + if (!shouldNotificationSoundBeThrottled(c)) { + allConversationsShouldBeThrottled = false; + break; + } + } + + if (allConversationsShouldBeThrottled) { + shouldNotify = false; + } + } + + updateNotification(shouldNotify, conversations); } } synchronized (mMissedCalls) { @@ -733,7 +749,7 @@ public class NotificationService { (!(this.mIsInForeground && this.mOpenConversation == null) || isScreenLocked) && !account.inGracePeriod() && !this.inMiniGracePeriod(account) && - !shouldNotificationSoundBeThrottled(conversation); + !shouldNotificationSoundBeThrottled(conversation.getUuid()); updateNotification(doNotify, Collections.singletonList(conversation.getUuid())); @@ -940,8 +956,8 @@ public class NotificationService { } } - private boolean shouldNotificationSoundBeThrottled(@Nullable Conversational conversation) { - if (conversation == null) { + private boolean shouldNotificationSoundBeThrottled(@Nullable String conversationUuid) { + if (conversationUuid == null) { return false; } @@ -951,7 +967,7 @@ public class NotificationService { return false; } - long lastNotificationTimestamp = ensureLastNotificationTimeByConversation().getLong(conversation.getUuid(), -1L); + long lastNotificationTimestamp = ensureLastNotificationTimeByConversation().getLong(conversationUuid, -1L); if (lastNotificationTimestamp <= 0L) { return false;