|
|
|
@ -31,12 +31,21 @@ public final class LokiGroupMessage : NSObject {
|
|
|
|
|
super.init()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@objc public convenience init(hexEncodedPublicKey: String, displayName: String, body: String, type: String, timestamp: UInt64) {
|
|
|
|
|
self.init(serverID: nil, hexEncodedPublicKey: hexEncodedPublicKey, displayName: displayName, body: body, type: type, timestamp: timestamp, quote: nil)
|
|
|
|
|
@objc public convenience init(hexEncodedPublicKey: String, displayName: String, body: String, type: String, timestamp: UInt64, quotedMessageTimestamp: UInt64, quoteeHexEncodedPublicKey: String?, quotedMessageBody: String?) {
|
|
|
|
|
let quote: Quote?
|
|
|
|
|
if quotedMessageTimestamp != 0, let quoteeHexEncodedPublicKey = quoteeHexEncodedPublicKey, let quotedMessageBody = quotedMessageBody {
|
|
|
|
|
quote = Quote(quotedMessageTimestamp: quotedMessageTimestamp, quoteeHexEncodedPublicKey: quoteeHexEncodedPublicKey, quotedMessageBody: quotedMessageBody)
|
|
|
|
|
} else {
|
|
|
|
|
quote = nil
|
|
|
|
|
}
|
|
|
|
|
self.init(serverID: nil, hexEncodedPublicKey: hexEncodedPublicKey, displayName: displayName, body: body, type: type, timestamp: timestamp, quote: quote)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal func toJSON() -> JSON {
|
|
|
|
|
let value: JSON = [ "timestamp" : timestamp, "from" : displayName, "source" : hexEncodedPublicKey ]
|
|
|
|
|
var value: JSON = [ "timestamp" : timestamp, "from" : displayName, "source" : hexEncodedPublicKey ]
|
|
|
|
|
if let quote = quote {
|
|
|
|
|
value["quote"] = [ "id" : quote.quotedMessageTimestamp, "author" : quote.quoteeHexEncodedPublicKey, "text" : quote.quotedMessageBody ]
|
|
|
|
|
}
|
|
|
|
|
return [ "text" : body, "annotations": [ [ "type" : type, "value" : value ] ] ]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|