sync lash hash with expiration to the backend server

pull/149/head
ryanzhao 5 years ago
parent ec1a468aab
commit e28dcfdd0c

@ -1 +1 @@
Subproject commit fede6eca060a60c0232bf7f1328462a27728d823
Subproject commit 703ae5f95474bb0b4d506449c55b7f99801f1e94

@ -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).")

@ -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" ]

Loading…
Cancel
Save