|
|
@ -66,19 +66,21 @@ public final class BackgroundPoller : NSObject {
|
|
|
|
return SnodeAPI.getSwarm(for: publicKey).then(on: DispatchQueue.main) { swarm -> Promise<Void> in
|
|
|
|
return SnodeAPI.getSwarm(for: publicKey).then(on: DispatchQueue.main) { swarm -> Promise<Void> in
|
|
|
|
guard let snode = swarm.randomElement() else { throw SnodeAPI.Error.generic }
|
|
|
|
guard let snode = swarm.randomElement() else { throw SnodeAPI.Error.generic }
|
|
|
|
return attempt(maxRetryCount: 4, recoveringOn: DispatchQueue.main) {
|
|
|
|
return attempt(maxRetryCount: 4, recoveringOn: DispatchQueue.main) {
|
|
|
|
var promises: [SnodeAPI.RawResponsePromise] = []
|
|
|
|
|
|
|
|
var namespaces: [Int] = []
|
|
|
|
var namespaces: [Int] = []
|
|
|
|
// We have to poll for both namespace 0 and -10 when hardfork == 19 && softfork == 0
|
|
|
|
let promises: [SnodeAPI.RawResponsePromise] = {
|
|
|
|
if SnodeAPI.hardfork <= 19, SnodeAPI.softfork == 0 {
|
|
|
|
if SnodeAPI.hardfork >= 19 && SnodeAPI.softfork >= 1 {
|
|
|
|
let promise = SnodeAPI.getRawClosedGroupMessagesFromDefaultNamespace(from: snode, associatedWith: publicKey)
|
|
|
|
namespaces = [ SnodeAPI.closedGroupNamespace ]
|
|
|
|
promises.append(promise)
|
|
|
|
return [ SnodeAPI.getRawMessages(from: snode, associatedWith: publicKey, authenticated: false) ]
|
|
|
|
namespaces.append(SnodeAPI.defaultNamespace)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if SnodeAPI.hardfork >= 19 {
|
|
|
|
if SnodeAPI.hardfork >= 19 && SnodeAPI.softfork >= 0 {
|
|
|
|
namespaces = [ SnodeAPI.defaultNamespace, SnodeAPI.closedGroupNamespace ]
|
|
|
|
let promise = SnodeAPI.getRawMessages(from: snode, associatedWith: publicKey, authenticated: false)
|
|
|
|
return [ SnodeAPI.getRawClosedGroupMessagesFromDefaultNamespace(from: snode, associatedWith: publicKey),
|
|
|
|
promises.append(promise)
|
|
|
|
SnodeAPI.getRawMessages(from: snode, associatedWith: publicKey, authenticated: false)]
|
|
|
|
namespaces.append(SnodeAPI.closedGroupNamespace)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
namespaces = [ SnodeAPI.defaultNamespace ]
|
|
|
|
|
|
|
|
return [ SnodeAPI.getRawClosedGroupMessagesFromDefaultNamespace(from: snode, associatedWith: publicKey) ]
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
return when(resolved: promises).then(on: DispatchQueue.main) { results -> Promise<Void> in
|
|
|
|
return when(resolved: promises).then(on: DispatchQueue.main) { results -> Promise<Void> in
|
|
|
|
var promises: [Promise<Void>] = []
|
|
|
|
var promises: [Promise<Void>] = []
|
|
|
|
var index = 0
|
|
|
|
var index = 0
|
|
|
|