From e28dcfdd0c1bb64272301be8e650527e8f6dabc2 Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Thu, 2 Apr 2020 11:57:25 +1100 Subject: [PATCH] sync lash hash with expiration to the backend server --- Pods | 2 +- SignalServiceKit/src/Loki/API/LokiAPI.swift | 2 +- .../src/Loki/Utilities/LokiPushNotificationManager.swift | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Pods b/Pods index fede6eca0..703ae5f95 160000 --- a/Pods +++ b/Pods @@ -1 +1 @@ -Subproject commit fede6eca060a60c0232bf7f1328462a27728d823 +Subproject commit 703ae5f95474bb0b4d506449c55b7f99801f1e94 diff --git a/SignalServiceKit/src/Loki/API/LokiAPI.swift b/SignalServiceKit/src/Loki/API/LokiAPI.swift index 3f55bee45..7dedb1353 100644 --- a/SignalServiceKit/src/Loki/API/LokiAPI.swift +++ b/SignalServiceKit/src/Loki/API/LokiAPI.swift @@ -271,7 +271,7 @@ public final class LokiAPI : NSObject { if let lastMessage = rawMessages.last, let hashValue = lastMessage["hash"] as? String, let expirationDate = lastMessage["expiration"] as? Int { setLastMessageHashValue(for: target, hashValue: hashValue, expirationDate: UInt64(expirationDate)) if UserDefaults.standard[.isUsingFullAPNs] { - LokiPushNotificationManager.acknowledgeDeliveryForMessage(with: hashValue, hexEncodedPublicKey: userHexEncodedPublicKey) + LokiPushNotificationManager.acknowledgeDeliveryForMessage(with: hashValue, expiration: expirationDate, hexEncodedPublicKey: userHexEncodedPublicKey) } } else if (!rawMessages.isEmpty) { print("[Loki] Failed to update last message hash value from: \(rawMessages).") diff --git a/SignalServiceKit/src/Loki/Utilities/LokiPushNotificationManager.swift b/SignalServiceKit/src/Loki/Utilities/LokiPushNotificationManager.swift index e339c5978..7785693b7 100644 --- a/SignalServiceKit/src/Loki/Utilities/LokiPushNotificationManager.swift +++ b/SignalServiceKit/src/Loki/Utilities/LokiPushNotificationManager.swift @@ -74,9 +74,11 @@ final class LokiPushNotificationManager : NSObject { }) } - @objc(acknowledgeDeliveryForMessageWithHash:hexEncodedPublicKey:) - static func acknowledgeDeliveryForMessage(with hash: String, hexEncodedPublicKey: String) { - let parameters: [String : Any] = [ "lastHash" : hash, "pubKey" : hexEncodedPublicKey] + @objc(acknowledgeDeliveryForMessageWithHash:expiration:hexEncodedPublicKey:) + static func acknowledgeDeliveryForMessage(with hash: String, expiration:Int, hexEncodedPublicKey: String) { + let parameters: [String : Any] = [ "lastHash" : hash, + "pubKey" : hexEncodedPublicKey, + "expiration": expiration] let url = URL(string: server + "acknowledge_message_delivery")! let request = TSRequest(url: url, method: "POST", parameters: parameters) request.allHTTPHeaderFields = [ "Content-Type" : "application/json" ]