Process sync response before decrypting call invite

This commit is contained in:
ismailgulek
2021-02-01 18:00:45 +03:00
parent f72ec5f0fc
commit ce36e53cd6
@@ -547,15 +547,24 @@ Matrix session observer used to detect new opened sessions.
// when we have a VoIP push while the application is killed, session.callManager will not be ready yet. Configure it.
[[AppDelegate theDelegate] configureCallManagerIfRequiredForSession:session];
if (lastCallInvite.isEncrypted)
{
[session decryptEvent:lastCallInvite inTimeline:nil];
}
NSLog(@"[PushNotificationService] didReceiveIncomingPushWithPayload: lastCallInvite: %@", lastCallInvite);
if ([lastCallInvite.eventId isEqualToString:eventId])
{
dispatch_group_t dispatchGroup = dispatch_group_create();
dispatch_group_enter(dispatchGroup);
[session handleBackgroundSyncCacheIfRequiredWithCompletion:^{
dispatch_group_leave(dispatchGroup);
}];
if (lastCallInvite.isEncrypted && ![session decryptEvent:lastCallInvite inTimeline:nil])
{
NSLog(@"[PushNotificationService] didReceiveIncomingPushWithPayload: Failed to decrypt the call invite event: %@", eventId);
completion();
return;
}
[session.callManager handleCallEvent:lastCallInvite];
MXCall *call = [session.callManager callWithCallId:lastCallInvite.content[@"call_id"]];
if (call)
@@ -563,8 +572,11 @@ Matrix session observer used to detect new opened sessions.
[session.callManager.callKitAdapter reportIncomingCall:call];
NSLog(@"[PushNotificationService] didReceiveIncomingPushWithPayload: Reporting new call in room %@ for the event: %@", roomId, eventId);
// After reporting the call, we can continue async. Launch a background sync to handle call answers/declines on other devices of the user.
[self launchBackgroundSync];
// Wait for the sync response in cache to be processed for data integrity.
dispatch_group_notify(dispatchGroup, dispatch_get_main_queue(), ^{
// After reporting the call, we can continue async. Launch a background sync to handle call answers/declines on other devices of the user.
[self launchBackgroundSync];
});
}
else
{