Skip to content

Commit

Permalink
Merge pull request #1062 from tchapgouv/1005-appels-voip-recurrents
Browse files Browse the repository at this point in the history
Ignorer les notifications d'appel VoIP trop anciennes
  • Loading branch information
NicolasBuquet authored Jun 26, 2024
2 parents 3a21646 + e29e3e3 commit c8da058
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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

0 comments on commit c8da058

Please sign in to comment.