Match Signal coding keys

This commit is contained in:
nielsandriesse 2020-11-09 08:15:44 +11:00
parent bef616b5bd
commit 4c69388c6c
7 changed files with 18 additions and 17 deletions

View File

@ -16,12 +16,12 @@ public final class ExpirationTimerUpdate : ControlMessage {
// MARK: Coding // MARK: Coding
public required init?(coder: NSCoder) { public required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
if let duration = coder.decodeObject(forKey: "duration") as! UInt32? { self.duration = duration } if let duration = coder.decodeObject(forKey: "durationSeconds") as! UInt32? { self.duration = duration }
} }
public override func encode(with coder: NSCoder) { public override func encode(with coder: NSCoder) {
super.encode(with: coder) super.encode(with: coder)
coder.encode(duration, forKey: "duration") coder.encode(duration, forKey: "durationSeconds")
} }
// MARK: Proto Conversion // MARK: Proto Conversion

View File

@ -19,12 +19,12 @@ public final class ReadReceipt : ControlMessage {
// MARK: Coding // MARK: Coding
public required init?(coder: NSCoder) { public required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
if let timestamps = coder.decodeObject(forKey: "timestamps") as! [UInt64]? { self.timestamps = timestamps } if let timestamps = coder.decodeObject(forKey: "messageTimestamps") as! [UInt64]? { self.timestamps = timestamps }
} }
public override func encode(with coder: NSCoder) { public override func encode(with coder: NSCoder) {
super.encode(with: coder) super.encode(with: coder)
coder.encode(timestamps, forKey: "timestamps") coder.encode(timestamps, forKey: "messageTimestamps")
} }
// MARK: Proto Conversion // MARK: Proto Conversion

View File

@ -7,7 +7,7 @@ public final class TypingIndicator : ControlMessage {
public override class var ttl: UInt64 { 30 * 1000 } public override class var ttl: UInt64 { 30 * 1000 }
// MARK: Kind // MARK: Kind
public enum Kind : String { public enum Kind : Int {
case started, stopped case started, stopped
static func fromProto(_ proto: SNProtoTypingMessage.SNProtoTypingMessageAction) -> Kind { static func fromProto(_ proto: SNProtoTypingMessage.SNProtoTypingMessageAction) -> Kind {
@ -37,12 +37,12 @@ public final class TypingIndicator : ControlMessage {
// MARK: Coding // MARK: Coding
public required init?(coder: NSCoder) { public required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
if let rawKind = coder.decodeObject(forKey: "kind") as! String? { kind = Kind(rawValue: rawKind) } if let rawKind = coder.decodeObject(forKey: "action") as! Int? { kind = Kind(rawValue: rawKind) }
} }
public override func encode(with coder: NSCoder) { public override func encode(with coder: NSCoder) {
super.encode(with: coder) super.encode(with: coder)
coder.encode(kind?.rawValue, forKey: "kind") coder.encode(kind?.rawValue, forKey: "action")
} }
// MARK: Proto Conversion // MARK: Proto Conversion

View File

@ -14,12 +14,12 @@ public extension VisibleMessage {
public required init?(coder: NSCoder) { public required init?(coder: NSCoder) {
if let title = coder.decodeObject(forKey: "title") as! String? { self.title = title } if let title = coder.decodeObject(forKey: "title") as! String? { self.title = title }
if let url = coder.decodeObject(forKey: "url") as! String? { self.url = url } if let url = coder.decodeObject(forKey: "urlString") as! String? { self.url = url }
} }
public func encode(with coder: NSCoder) { public func encode(with coder: NSCoder) {
coder.encode(title, forKey: "title") coder.encode(title, forKey: "title")
coder.encode(url, forKey: "url") coder.encode(url, forKey: "urlString")
} }
public static func fromProto(_ proto: SNProtoDataMessagePreview) -> LinkPreview? { public static func fromProto(_ proto: SNProtoDataMessagePreview) -> LinkPreview? {

View File

@ -16,14 +16,14 @@ public extension VisibleMessage {
public required init?(coder: NSCoder) { public required init?(coder: NSCoder) {
if let timestamp = coder.decodeObject(forKey: "timestamp") as! UInt64? { self.timestamp = timestamp } if let timestamp = coder.decodeObject(forKey: "timestamp") as! UInt64? { self.timestamp = timestamp }
if let publicKey = coder.decodeObject(forKey: "publicKey") as! String? { self.publicKey = publicKey } if let publicKey = coder.decodeObject(forKey: "authorId") as! String? { self.publicKey = publicKey }
if let text = coder.decodeObject(forKey: "text") as! String? { self.text = text } if let text = coder.decodeObject(forKey: "body") as! String? { self.text = text }
} }
public func encode(with coder: NSCoder) { public func encode(with coder: NSCoder) {
coder.encode(timestamp, forKey: "timestamp") coder.encode(timestamp, forKey: "timestamp")
coder.encode(publicKey, forKey: "publicKey") coder.encode(publicKey, forKey: "authorId")
coder.encode(text, forKey: "text") coder.encode(text, forKey: "body")
} }
public static func fromProto(_ proto: SNProtoDataMessageQuote) -> Quote? { public static func fromProto(_ proto: SNProtoDataMessageQuote) -> Quote? {

View File

@ -22,14 +22,14 @@ public final class VisibleMessage : Message {
// MARK: Coding // MARK: Coding
public required init?(coder: NSCoder) { public required init?(coder: NSCoder) {
super.init(coder: coder) super.init(coder: coder)
if let text = coder.decodeObject(forKey: "text") as! String? { self.text = text } if let text = coder.decodeObject(forKey: "body") as! String? { self.text = text }
if let attachmentIDs = coder.decodeObject(forKey: "attachmentIDs") as! [String]? { self.attachmentIDs = attachmentIDs } if let attachmentIDs = coder.decodeObject(forKey: "attachments") as! [String]? { self.attachmentIDs = attachmentIDs }
} }
public override func encode(with coder: NSCoder) { public override func encode(with coder: NSCoder) {
super.encode(with: coder) super.encode(with: coder)
coder.encode(text, forKey: "text") coder.encode(text, forKey: "body")
coder.encode(attachmentIDs, forKey: "attachmentIDs") coder.encode(attachmentIDs, forKey: "attachments")
} }
// MARK: Proto Conversion // MARK: Proto Conversion

View File

@ -46,6 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
_parameters = parameters ?: @{}; _parameters = parameters ?: @{};
[self setHTTPMethod:method]; [self setHTTPMethod:method];
return self; return self;