mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.4 KiB
Swift
47 lines
1.4 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
public class GetMessagesResponse: SnodeResponse {
|
|
private enum CodingKeys: String, CodingKey {
|
|
case messages
|
|
case more
|
|
}
|
|
|
|
public class RawMessage: Codable {
|
|
private enum CodingKeys: String, CodingKey {
|
|
case base64EncodedDataString = "data"
|
|
case expiration
|
|
case hash
|
|
case timestampMs = "timestamp"
|
|
}
|
|
|
|
public let base64EncodedDataString: String
|
|
public let expiration: Int64?
|
|
public let hash: String
|
|
public let timestampMs: Int64
|
|
}
|
|
|
|
public let messages: [RawMessage]
|
|
public let more: Bool
|
|
|
|
// MARK: - Initialization
|
|
|
|
required init(from decoder: Decoder) throws {
|
|
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
|
|
|
|
messages = try container.decode([RawMessage].self, forKey: .messages)
|
|
more = try container.decode(Bool.self, forKey: .more)
|
|
|
|
try super.init(from: decoder)
|
|
}
|
|
|
|
public override func encode(to encoder: any Encoder) throws {
|
|
var container: KeyedEncodingContainer<CodingKeys> = encoder.container(keyedBy: CodingKeys.self)
|
|
try container.encode(messages, forKey: .messages)
|
|
try container.encode(more, forKey: .more)
|
|
|
|
try super.encode(to: encoder)
|
|
}
|
|
}
|