From 111bbd06462e0850e7f45cd610651e08888b4695 Mon Sep 17 00:00:00 2001
From: ryanzhao <ryanzhaors@qq.com>
Date: Wed, 4 Aug 2021 15:57:37 +1000
Subject: [PATCH] handle unsend requests in NSE

---
 .../NotificationServiceExtension.swift                       | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/SessionNotificationServiceExtension/NotificationServiceExtension.swift b/SessionNotificationServiceExtension/NotificationServiceExtension.swift
index 983fdb7ce..6ad0242b5 100644
--- a/SessionNotificationServiceExtension/NotificationServiceExtension.swift
+++ b/SessionNotificationServiceExtension/NotificationServiceExtension.swift
@@ -67,6 +67,11 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
                                 return self.completeSilenty()
                             }
                         }
+                        // Store the notification identifier for unsend request to cancel this notification
+                        tsIncomingMessage.setNotificationIdentifier(request.identifier, transaction: transaction)
+                    case let unsendRequest as UnsendRequest:
+                        MessageReceiver.handleUnsendRequest(unsendRequest, using: transaction)
+                        return self.completeSilenty()
                     case let closedGroupControlMessage as ClosedGroupControlMessage:
                         // TODO: We could consider actually handling the update here. Not sure if there's enough time though, seeing as though
                         // in some cases we need to send messages (e.g. our sender key) to a number of other users.