forked from TelegramMessenger/Telegram-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTelegramChannel.swift
38 lines (30 loc) · 1.02 KB
/
TelegramChannel.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
import PostboxDataTypes
import PostboxCoding
public enum TelegramChannelInfo: Int32 {
case broadcast = 0
case group = 1
}
public final class TelegramChannel: Peer {
public let id: PeerId
public let username: String?
public let info: TelegramChannelInfo
public let associatedPeerId: PeerId? = nil
public let notificationSettingsPeerId: PeerId? = nil
public init(decoder: PostboxDecoder) {
self.id = PeerId(decoder.decodeInt64ForKey("i", orElse: 0))
self.username = decoder.decodeOptionalStringForKey("un")
self.info = TelegramChannelInfo(rawValue: decoder.decodeInt32ForKey("i.t", orElse: 0)) ?? .broadcast
}
public func encode(_ encoder: PostboxEncoder) {
preconditionFailure()
}
public func isEqual(_ other: Peer) -> Bool {
guard let other = other as? TelegramChannel else {
return false
}
if self.username != other.username {
return false
}
return true
}
}