mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-16 10:30:08 +00:00
38 lines
910 B
Swift
38 lines
910 B
Swift
import Foundation
|
|
#if os(macOS)
|
|
import PostboxMac
|
|
#else
|
|
import Postbox
|
|
#endif
|
|
|
|
public struct ExportedInvitation: PostboxCoding, Equatable {
|
|
public let link: String
|
|
|
|
init(link: String) {
|
|
self.link = link
|
|
}
|
|
|
|
public init(decoder: PostboxDecoder) {
|
|
self.link = decoder.decodeStringForKey("l", orElse: "")
|
|
}
|
|
|
|
public func encode(_ encoder: PostboxEncoder) {
|
|
encoder.encodeString(self.link, forKey: "l")
|
|
}
|
|
|
|
public static func ==(lhs: ExportedInvitation, rhs: ExportedInvitation) -> Bool {
|
|
return lhs.link == rhs.link
|
|
}
|
|
}
|
|
|
|
extension ExportedInvitation {
|
|
init?(apiExportedInvite: Api.ExportedChatInvite) {
|
|
switch apiExportedInvite {
|
|
case .chatInviteEmpty:
|
|
return nil
|
|
case let .chatInviteExported(link):
|
|
self = ExportedInvitation(link: link)
|
|
}
|
|
}
|
|
}
|