From 26625980bd1c66cf6489e20a1880161dc92a34fc Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 9 May 2019 09:45:31 +1000 Subject: [PATCH] Fix message sending params. Disable ProfileFetcherJob. --- SignalMessaging/profiles/ProfileFetcherJob.swift | 4 ++++ SignalServiceKit/src/Loki/LokiMessage.swift | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/SignalMessaging/profiles/ProfileFetcherJob.swift b/SignalMessaging/profiles/ProfileFetcherJob.swift index e1608b670..4682b9c9b 100644 --- a/SignalMessaging/profiles/ProfileFetcherJob.swift +++ b/SignalMessaging/profiles/ProfileFetcherJob.swift @@ -79,6 +79,9 @@ public class ProfileFetcherJob: NSObject { public func run(recipientIds: [String]) { AssertIsOnMainThread() + /* Loki: Original Code + * Disabled as we don't have an endpoint for fetching profiles + * ========================= guard CurrentAppContext().isMainApp else { // Only refresh profiles in the MainApp to decrease the chance of missed SN notifications // in the AppExtension for our users who choose not to verify contacts. @@ -103,6 +106,7 @@ public class ProfileFetcherJob: NSObject { self.getAndUpdateProfile(recipientId: recipientId) } } + */ } enum ProfileFetcherJobError: Error { diff --git a/SignalServiceKit/src/Loki/LokiMessage.swift b/SignalServiceKit/src/Loki/LokiMessage.swift index 02668c3b6..889960a49 100644 --- a/SignalServiceKit/src/Loki/LokiMessage.swift +++ b/SignalServiceKit/src/Loki/LokiMessage.swift @@ -9,7 +9,7 @@ public struct LokiMessage { let ttl: UInt64 /// When the proof of work was calculated, if applicable. /// - /// - Note: Expressed as seconds since 00:00:00 UTC on 1 January 1970. + /// - Note: Expressed as milliseconds since 00:00:00 UTC on 1 January 1970. let timestamp: UInt64? /// The base 64 encoded proof of work, if applicable. let nonce: String? @@ -29,7 +29,8 @@ public struct LokiMessage { let data = signalMessage["content"] as! String let ttl = LokiAPI.defaultMessageTTL if isPoWRequired { - let timestamp = UInt64(Date().timeIntervalSince1970) + // timeIntervalSince1970 returns timestamp in seconds but the storage server only accepts timestamp in milliseconds + let timestamp = UInt64(Date().timeIntervalSince1970 * 1000) if let nonce = ProofOfWork.calculate(data: data, pubKey: destination, timestamp: timestamp, ttl: ttl) { let result = LokiMessage(destination: destination, data: data, ttl: ttl, timestamp: timestamp, nonce: nonce) seal.fulfill(result)