minor fix

pull/622/head
ryanzhao 2 years ago
parent 7cc887267f
commit 372e87e70f

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

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

@ -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<Set<RawResponsePromise>> {
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<Set<RawResponsePromise>> {
let storage = SNSnodeKitConfiguration.shared.storage

Loading…
Cancel
Save