30 lines
717 B
Swift
30 lines
717 B
Swift
import Foundation
|
|
import monalxmpp
|
|
|
|
struct Message: Identifiable {
|
|
let accountId: Int
|
|
let participantJid: String
|
|
let dbId: Int
|
|
let stanzaId: String
|
|
let timestamp: Date
|
|
let body: String
|
|
let isInbound: Bool
|
|
let encrypted: Bool
|
|
|
|
var id: String {
|
|
"\(accountId)|\(dbId)"
|
|
}
|
|
|
|
init?(_ obj: MLMessage) {
|
|
guard let accId = obj.accountID as? Int, let dbId = obj.messageDBId as? Int else { return nil }
|
|
accountId = accId
|
|
participantJid = obj.participantJid
|
|
self.dbId = dbId
|
|
stanzaId = obj.stanzaId
|
|
timestamp = obj.timestamp
|
|
body = obj.messageText
|
|
isInbound = obj.inbound
|
|
encrypted = obj.encrypted
|
|
}
|
|
}
|