From 69599419d384f6c9cbcc49c66e6a4b3ef9316900 Mon Sep 17 00:00:00 2001 From: Max Radermacher Date: Fri, 10 Jan 2025 15:24:40 -0600 Subject: [PATCH] Stop reading deprecated serverEpochTime field --- SignalServiceKit/Util/RemoteConfigManager.swift | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SignalServiceKit/Util/RemoteConfigManager.swift b/SignalServiceKit/Util/RemoteConfigManager.swift index a6af3a8129..3edc980a05 100644 --- a/SignalServiceKit/Util/RemoteConfigManager.swift +++ b/SignalServiceKit/Util/RemoteConfigManager.swift @@ -854,8 +854,8 @@ public class RemoteConfigManagerImpl: RemoteConfigManager { let fetchedConfig = try await fetchRemoteConfig(auth: account.chatServiceAuth) let clockSkew: TimeInterval - if let serverEpochTimeSeconds = fetchedConfig.serverEpochTimeSeconds { - let dateAccordingToServer = Date(timeIntervalSince1970: TimeInterval(serverEpochTimeSeconds)) + if let serverEpochTimeMs = fetchedConfig.serverEpochTimeMs { + let dateAccordingToServer = Date(timeIntervalSince1970: TimeInterval(serverEpochTimeMs) / 1000) clockSkew = dateAccordingToServer.timeIntervalSince(Date()) } else { clockSkew = 0 @@ -981,8 +981,8 @@ public class RemoteConfigManagerImpl: RemoteConfigManager { } private struct FetchedRemoteConfigResponse { - public let items: [String: FetchedRemoteConfigItem] - public let serverEpochTimeSeconds: UInt64? + let items: [String: FetchedRemoteConfigItem] + let serverEpochTimeMs: UInt64? } private func fetchRemoteConfig(auth: ChatServiceAuth) async throws -> FetchedRemoteConfigResponse { @@ -998,7 +998,8 @@ public class RemoteConfigManagerImpl: RemoteConfigManager { } let config: [[String: Any]] = try parser.required(key: "config") - let serverEpochTimeSeconds: UInt64? = try parser.optional(key: "serverEpochTime") + let serverEpochTimeMs = response.responseHeaders["x-signal-timestamp"].flatMap(UInt64.init(_:)) + owsAssertDebug(serverEpochTimeMs != nil, "Must have X-Signal-Timestamp.") let items: [String: FetchedRemoteConfigItem] = try config.reduce([:]) { accum, item in var accum = accum @@ -1020,7 +1021,7 @@ public class RemoteConfigManagerImpl: RemoteConfigManager { return FetchedRemoteConfigResponse( items: items, - serverEpochTimeSeconds: serverEpochTimeSeconds + serverEpochTimeMs: serverEpochTimeMs ) }