mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-17 11:00:07 +00:00
28 lines
1014 B
Swift
28 lines
1014 B
Swift
import Foundation
|
|
import Postbox
|
|
|
|
func apiInputPeer(_ peer: Peer) -> Api.InputPeer? {
|
|
switch peer {
|
|
case let user as TelegramUser where user.accessHash != nil:
|
|
return Api.InputPeer.inputPeerUser(userId: user.id.id, accessHash: user.accessHash!)
|
|
case let group as TelegramGroup:
|
|
if group.id.namespace == Namespaces.Peer.CloudGroup {
|
|
return Api.InputPeer.inputPeerChat(chatId: group.id.id)
|
|
} else if group.id.namespace == Namespaces.Peer.CloudChannel {
|
|
return Api.InputPeer.inputPeerChannel(channelId: group.id.id, accessHash: group.accessHash)
|
|
} else {
|
|
return nil
|
|
}
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func apiInputChannel(_ peer: Peer) -> Api.InputChannel? {
|
|
if let channel = peer as? TelegramGroup, channel.accessHash != 0 {
|
|
return Api.InputChannel.inputChannel(channelId: channel.id.id, accessHash: channel.accessHash)
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|