diff --git a/wire-ios-request-strategy/Sources/Notifications/Push Notifications/Notification Types/Content/ZMLocalNotification+Events.swift b/wire-ios-request-strategy/Sources/Notifications/Push Notifications/Notification Types/Content/ZMLocalNotification+Events.swift index f28fa94e844..fcfb497e9f3 100644 --- a/wire-ios-request-strategy/Sources/Notifications/Push Notifications/Notification Types/Content/ZMLocalNotification+Events.swift +++ b/wire-ios-request-strategy/Sources/Notifications/Push Notifications/Notification Types/Content/ZMLocalNotification+Events.swift @@ -16,6 +16,7 @@ // along with this program. If not, see http://www.gnu.org/licenses/. // +import Foundation import WireDataModel public extension ZMLocalNotification { @@ -191,6 +192,17 @@ private class ConversationCreateEventNotificationBuilder: EventNotificationBuild LocalNotificationType.event(.conversationCreated) } + override func shouldCreateNotification() -> Bool { + if conversation == nil { + // WPB-8946: fixes bug: notifications shown even though availability is busy or away + let availability = moc.performAndWait { ZMUser.selfUser(in: moc).availability } + return [.none, .available].contains(availability) + } + + // default behavior + return super.shouldCreateNotification() + } + } // MARK: - Conversation Delete Event @@ -322,7 +334,12 @@ private class NewMessageNotificationBuilder: EventNotificationBuilder { "Not creating local notification for message with nonce = \(event.messageNonce) because conversation is silenced" ) return false + } else if conversation == nil { + // WPB-8946: fixes bug: notifications shown even though availability is busy or away + let availability = moc.performAndWait { ZMUser.selfUser(in: moc).availability } + return [.none, .available].contains(availability) } + if ZMUser.selfUser(in: moc).remoteIdentifier == event.senderUUID { return false }