Newer
Older
import Models
import Bindings
extension Contact {
init(with contact: BindingsContact, status: Contact.Status) {
self.init(
photo: nil,
userId: contact.getID()!,
email: contact.retrieve(fact: .email),
phone: contact.retrieve(fact: .phone),
status: status,
marshaled: try! contact.marshal(),
username: contact.retrieve(fact: .username) ?? "",
nickname: nil,
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
)
}
}
extension Message {
init(with message: BindingsMessage, meMarshalled: Data) {
guard let payload = try? Payload(with: message.getPayload()!) else { fatalError() }
self.init(
sender: message.getSender()!,
receiver: meMarshalled,
payload: payload,
unread: true,
timestamp: Int(message.getTimestampNano()),
uniqueId: message.getID()!,
status: .received,
roundURL: message.getRoundURL()
)
}
}
extension GroupMessage {
init(with message: BindingsGroupMessageReceive) {
guard let payload = try? Payload(with: message.getPayload()!) else { fatalError() }
self.init(
sender: message.getSenderID()!,
groupId: message.getGroupID()!,
payload: payload,
unread: true,
timestamp: Int(message.getTimestampNano()),
uniqueId: message.getMessageID()!,
status: .received,
roundURL: message.getRoundURL()
)
}
}