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.
session-ios/SessionMessagingKit/Messages/Visible Message/VisibleMessage.swift

44 lines
1.6 KiB
Swift

@objc(SNVisibleMessage)
public final class VisibleMessage : Message {
public var text: String?
public var attachmentIDs: [String] = []
public var quote: Quote?
public var linkPreview: LinkPreview?
public var contact: Contact?
public var profile: Profile?
5 years ago
// MARK: Initialization
public override init() { super.init() }
5 years ago
// MARK: Coding
public required init?(coder: NSCoder) {
super.init(coder: coder)
if let text = coder.decodeObject(forKey: "text") as! String? { self.text = text }
if let attachmentIDs = coder.decodeObject(forKey: "attachmentIDs") as! [String]? { self.attachmentIDs = attachmentIDs }
}
public override func encode(with coder: NSCoder) {
super.encode(with: coder)
coder.encode(text, forKey: "text")
coder.encode(attachmentIDs, forKey: "attachmentIDs")
}
// MARK: Proto Conversion
public override class func fromProto(_ proto: SNProtoContent) -> VisibleMessage? {
guard let dataMessage = proto.dataMessage else { return nil }
let result = VisibleMessage()
result.text = dataMessage.body
result.attachmentIDs = [] // TODO
if let quoteProto = dataMessage.quote, let quote = Quote.fromProto(quoteProto) { result.quote = quote }
if let linkPreviewProto = dataMessage.preview.first, let linkPreview = LinkPreview.fromProto(linkPreviewProto) { result.linkPreview = linkPreview }
// TODO: Contact
if let profile = Profile.fromProto(dataMessage) { result.profile = profile }
return result
5 years ago
}
public override func toProto() -> SNProtoContent? {
return nil
}
}