-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMessages.swift
47 lines (36 loc) · 1000 Bytes
/
Messages.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
//
// Messages.swift
// MotorChat
//
// Created by Stephan Dowless on 2/21/17.
// Copyright © 2017 Stephan Dowless. All rights reserved.
//
import Foundation
import Firebase
class Messages {
var fromId: String?
var toId: String?
var text: String?
var timestamp: Int?
init(messageDict: Dictionary<String, AnyObject>) {
if let text = messageDict["text"] as? String {
self.text = text
}
if let toId = messageDict["toId"] as? String {
self.toId = toId
}
if let fromId = messageDict["fromId"] as? String {
self.fromId = fromId
}
if let timestamp = messageDict["timestamp"] as? Int {
self.timestamp = timestamp
}
}
func chatPartnerId() -> String? {
if fromId == FIRAuth.auth()?.currentUser?.uid {
return toId
} else {
return fromId
}
}
}