From 372e87e70f792d12c6f80fd5a7708346cd5e4b2c Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 4 May 2022 16:36:15 +1000 Subject: [PATCH] minor fix --- Session/Utilities/BackgroundPoller.swift | 2 +- .../Pollers/ClosedGroupPoller.swift | 2 +- SessionSnodeKit/SnodeAPI.swift | 12 +++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Session/Utilities/BackgroundPoller.swift b/Session/Utilities/BackgroundPoller.swift index c7d1b3c28..2480c16de 100644 --- a/Session/Utilities/BackgroundPoller.swift +++ b/Session/Utilities/BackgroundPoller.swift @@ -50,7 +50,7 @@ public final class BackgroundPoller : NSObject { let job = MessageReceiveJob(data: data, serverHash: json["hash"] as? String, isBackgroundPoll: true) return job.execute() } - let namespace = authenticated ? SnodeAPI.defaultNamespace : SnodeAPI.unauthenticatedNamespace + let namespace = authenticated ? SnodeAPI.defaultNamespace : SnodeAPI.closedGroupNamespace // Now that the MessageReceiveJob's have been created we can update the `lastMessageHash` value SnodeAPI.updateLastMessageHashValueIfPossible(for: snode, namespace: namespace, associatedWith: publicKey, from: lastRawMessage) diff --git a/SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift b/SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift index 83f3127c1..33a3869ae 100644 --- a/SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift +++ b/SessionMessagingKit/Sending & Receiving/Pollers/ClosedGroupPoller.swift @@ -132,7 +132,7 @@ public final class ClosedGroupPoller : NSObject { } // Now that the MessageReceiveJob's have been created we can update the `lastMessageHash` value - SnodeAPI.updateLastMessageHashValueIfPossible(for: snode, namespace: SnodeAPI.unauthenticatedNamespace, associatedWith: groupPublicKey, from: lastRawMessage) + SnodeAPI.updateLastMessageHashValueIfPossible(for: snode, namespace: SnodeAPI.closedGroupNamespace, associatedWith: groupPublicKey, from: lastRawMessage) } promise.catch2 { error in SNLog("Polling failed for closed group with public key: \(groupPublicKey) due to error: \(error).") diff --git a/SessionSnodeKit/SnodeAPI.swift b/SessionSnodeKit/SnodeAPI.swift index 12b10c708..3f055319a 100644 --- a/SessionSnodeKit/SnodeAPI.swift +++ b/SessionSnodeKit/SnodeAPI.swift @@ -25,7 +25,7 @@ public final class SnodeAPI : NSObject { // MARK: Namespaces public static let defaultNamespace = 0 - public static let unauthenticatedNamespace = -10 + public static let closedGroupNamespace = -10 public static let configNamespace = 5 // MARK: Hardfork version @@ -414,7 +414,7 @@ public final class SnodeAPI : NSObject { } // MARK: Retrieve - + // Not in use until we can batch delete and store config messages public static func getConfigMessages(from snode: Snode, associatedWith publicKey: String) -> RawResponsePromise { let (promise, seal) = RawResponsePromise.pending() Threading.workQueue.async { @@ -474,7 +474,7 @@ public final class SnodeAPI : NSObject { return invoke(.getMessages, on: snode, associatedWith: publicKey, parameters: parameters) } - private static func getMessagesUnauthenticated(from snode: Snode, associatedWith publicKey: String, namespace: Int = unauthenticatedNamespace) -> RawResponsePromise { + private static func getMessagesUnauthenticated(from snode: Snode, associatedWith publicKey: String, namespace: Int = closedGroupNamespace) -> RawResponsePromise { let storage = SNSnodeKitConfiguration.shared.storage // Get last message hash @@ -493,13 +493,11 @@ public final class SnodeAPI : NSObject { // MARK: Store public static func sendMessage(_ message: SnodeMessage, isClosedGroupMessage: Bool, isConfigMessage: Bool) -> Promise> { - if isConfigMessage { - return sendMessageWithAuthentication(message, namespace: configNamespace) - } - let namespace = isClosedGroupMessage ? unauthenticatedNamespace : defaultNamespace + let namespace = isClosedGroupMessage ? closedGroupNamespace : defaultNamespace return sendMessageUnauthenticated(message, namespace: namespace) } + // Not in use until we can batch delete and store config messages private static func sendMessageWithAuthentication(_ message: SnodeMessage, namespace: Int) -> Promise> { let storage = SNSnodeKitConfiguration.shared.storage