mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Additional call-related functions [temp]
This commit is contained in:
parent
26f7d180a7
commit
b732a6c578
@ -141,3 +141,43 @@ func _internal_joinLinkInformation(_ hash: String, account: Account) -> Signal<E
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final class JoinCallLinkInformation {
|
||||
public let inviter: EnginePeer?
|
||||
public let members: [EnginePeer]
|
||||
public let totalMemberCount: Int
|
||||
|
||||
public init(inviter: EnginePeer?, members: [EnginePeer], totalMemberCount: Int) {
|
||||
self.inviter = inviter
|
||||
self.members = members
|
||||
self.totalMemberCount = totalMemberCount
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_joinCallLinkInformation(_ hash: String, account: Account) -> Signal<JoinCallLinkInformation, JoinLinkInfoError> {
|
||||
//TODO:release
|
||||
|
||||
let invite: Signal<Api.ChatInvite?, JoinLinkInfoError> = account.network.request(Api.functions.messages.checkChatInvite(hash: hash), automaticFloodWait: false)
|
||||
|> map(Optional.init)
|
||||
|> `catch` { error -> Signal<Api.ChatInvite?, JoinLinkInfoError> in
|
||||
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||
return .fail(.flood)
|
||||
} else {
|
||||
return .single(nil)
|
||||
}
|
||||
}
|
||||
|
||||
return invite
|
||||
|> mapToSignal { result -> Signal<JoinCallLinkInformation, JoinLinkInfoError> in
|
||||
if let result {
|
||||
switch result {
|
||||
case let .chatInvite(_, _, _, _, participantsCount, participants, _, _, _, _):
|
||||
return .single(JoinCallLinkInformation(inviter: nil, members: participants?.map({ EnginePeer(TelegramUser(user: $0)) }) ?? [], totalMemberCount: Int(participantsCount)))
|
||||
default:
|
||||
return .fail(.generic)
|
||||
}
|
||||
} else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -837,6 +837,10 @@ public extension TelegramEngine {
|
||||
public func joinLinkInformation(_ hash: String) -> Signal<ExternalJoiningChatState, JoinLinkInfoError> {
|
||||
return _internal_joinLinkInformation(hash, account: self.account)
|
||||
}
|
||||
|
||||
public func joinCallLinkInformation(_ hash: String) -> Signal<JoinCallLinkInformation, JoinLinkInfoError> {
|
||||
return _internal_joinCallLinkInformation(hash, account: self.account)
|
||||
}
|
||||
|
||||
public func updatePeerTitle(peerId: PeerId, title: String) -> Signal<Void, UpdatePeerTitleError> {
|
||||
return _internal_updatePeerTitle(account: self.account, peerId: peerId, title: title)
|
||||
|
Loading…
x
Reference in New Issue
Block a user