minor fix

pull/622/head
ryanzhao 3 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) let job = MessageReceiveJob(data: data, serverHash: json["hash"] as? String, isBackgroundPoll: true)
return job.execute() 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 // Now that the MessageReceiveJob's have been created we can update the `lastMessageHash` value
SnodeAPI.updateLastMessageHashValueIfPossible(for: snode, namespace: namespace, associatedWith: publicKey, from: lastRawMessage) 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 // 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 promise.catch2 { error in
SNLog("Polling failed for closed group with public key: \(groupPublicKey) due to error: \(error).") 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 // MARK: Namespaces
public static let defaultNamespace = 0 public static let defaultNamespace = 0
public static let unauthenticatedNamespace = -10 public static let closedGroupNamespace = -10
public static let configNamespace = 5 public static let configNamespace = 5
// MARK: Hardfork version // MARK: Hardfork version
@ -414,7 +414,7 @@ public final class SnodeAPI : NSObject {
} }
// MARK: Retrieve // 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 { public static func getConfigMessages(from snode: Snode, associatedWith publicKey: String) -> RawResponsePromise {
let (promise, seal) = RawResponsePromise.pending() let (promise, seal) = RawResponsePromise.pending()
Threading.workQueue.async { Threading.workQueue.async {
@ -474,7 +474,7 @@ public final class SnodeAPI : NSObject {
return invoke(.getMessages, on: snode, associatedWith: publicKey, parameters: parameters) 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 let storage = SNSnodeKitConfiguration.shared.storage
// Get last message hash // Get last message hash
@ -493,13 +493,11 @@ public final class SnodeAPI : NSObject {
// MARK: Store // MARK: Store
public static func sendMessage(_ message: SnodeMessage, isClosedGroupMessage: Bool, isConfigMessage: Bool) -> Promise<Set<RawResponsePromise>> { public static func sendMessage(_ message: SnodeMessage, isClosedGroupMessage: Bool, isConfigMessage: Bool) -> Promise<Set<RawResponsePromise>> {
if isConfigMessage { let namespace = isClosedGroupMessage ? closedGroupNamespace : defaultNamespace
return sendMessageWithAuthentication(message, namespace: configNamespace)
}
let namespace = isClosedGroupMessage ? unauthenticatedNamespace : defaultNamespace
return sendMessageUnauthenticated(message, namespace: namespace) 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>> { private static func sendMessageWithAuthentication(_ message: SnodeMessage, namespace: Int) -> Promise<Set<RawResponsePromise>> {
let storage = SNSnodeKitConfiguration.shared.storage let storage = SNSnodeKitConfiguration.shared.storage

Loading…
Cancel
Save