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

Ignorer les notifications d'appel VoIP trop anciennes #1062

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions RiotNSE/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class NotificationService: UNNotificationServiceExtension {
enum Constants {
static let voipPushRequestTimeout: TimeInterval = 15
static let timeNeededToSendVoIPPushes: TimeInterval = 20
static let tchapCallInviteNotificationDiscardDelta = 10.0 // Tchap: max age of call event before ignoring it
}
}

Expand Down Expand Up @@ -863,6 +864,17 @@ class NotificationService: UNNotificationServiceExtension {
// Starting from iOS 14.5, SDK can "Reports a new incoming call after your notification service extension decrypts a VoIP call request."
// See: https://developer.apple.com/documentation/callkit/cxprovider/3727263-reportnewincomingvoippushpayload

// from Element X : https://github.com/element-hq/element-x-ios/pull/2862/files#diff-1ff0fcebaadd2768e042e7bbafc1321cc5a73089ac1692dc3749492fa2881d91R203
// Checks if it's still time relevant (max 10 seconds old) and whether it should ring
//
// Should prevent ghost ringing when old m.call.invite are dispatched lately

let timestamp = Date(timeIntervalSince1970: TimeInterval(event.age / 1000))
guard abs(timestamp.timeIntervalSinceNow) < NSE.Constants.tchapCallInviteNotificationDiscardDelta else {
MXLog.info("Call notification is too old, handling as push notification")
return
}

// Build th payload expected by the application.
var payload = [String: String]()
payload["event_id"] = event.eventId
Expand Down
1 change: 1 addition & 0 deletions changelog.d/1005.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ignorer les notifications d'appel VoIP trop anciennes
Loading