Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip notification when away or busy - WPB-8946 #2438

Merged
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// along with this program. If not, see http://www.gnu.org/licenses/.
//

import Foundation
import WireDataModel

public extension ZMLocalNotification {
Expand Down Expand Up @@ -191,6 +192,17 @@ private class ConversationCreateEventNotificationBuilder: EventNotificationBuild
LocalNotificationType.event(.conversationCreated)
}

override func shouldCreateNotification() -> Bool {
caldrian marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down Expand Up @@ -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
}
Expand Down
Loading