mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
f30b383bb8
Updated the SharedConfigMessage type to have a TTL of 30 days Updated the SnodeAPI to have a 'poll' method to be more consistent with the OpenGroupAPI (it also does multiple things now so is cleaner) Added logic to limit the number of config messages to be retrieved per poll Added the 'ValidatableResponse' protocol to standardise SnodeAPI response validation Added the libSession version to the logs Fixed an issue where the user profile pic wouldn't get synced correctly due to memory going out of scope Fixed some threading issues Refactored the thread variants to follow the updated terminology (will think about refactoring other code areas later) Cleaned up the Combine error handling Started fixing broken unit tests
53 lines
1.9 KiB
Swift
53 lines
1.9 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
public class SnodeSwarmItem: Codable {
|
|
private enum CodingKeys: String, CodingKey {
|
|
case signatureBase64 = "signature"
|
|
|
|
case failed
|
|
case timeout
|
|
case code
|
|
case reason
|
|
case badPeerResponse = "bad_peer_response"
|
|
case queryFailure = "query_failure"
|
|
}
|
|
|
|
/// Should be present as long as the request didn't fail
|
|
public let signatureBase64: String?
|
|
|
|
/// `true` if the request failed, possibly accompanied by one of the following: `timeout`, `code`,
|
|
/// `reason`, `badPeerResponse`, `queryFailure`
|
|
public let failed: Bool
|
|
|
|
/// `true` if the inter-swarm request timed out
|
|
public let timeout: Bool?
|
|
|
|
/// `X` if the inter-swarm request returned error code `X`
|
|
public let code: Int?
|
|
|
|
/// a reason string, e.g. propagating a thrown exception messages
|
|
public let reason: String?
|
|
|
|
/// `true` if the peer returned an unparseable response
|
|
public let badPeerResponse: Bool?
|
|
|
|
/// `true` if the database failed to perform the query
|
|
public let queryFailure: Bool?
|
|
|
|
// MARK: - Initialization
|
|
|
|
public required init(from decoder: Decoder) throws {
|
|
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
|
|
|
|
signatureBase64 = try? container.decode(String.self, forKey: .signatureBase64)
|
|
failed = ((try? container.decode(Bool.self, forKey: .failed)) ?? false)
|
|
timeout = try? container.decode(Bool.self, forKey: .timeout)
|
|
code = try? container.decode(Int.self, forKey: .code)
|
|
reason = try? container.decode(String.self, forKey: .reason)
|
|
badPeerResponse = try? container.decode(Bool.self, forKey: .badPeerResponse)
|
|
queryFailure = try? container.decode(Bool.self, forKey: .queryFailure)
|
|
}
|
|
}
|