mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-03 11:21:06 +00:00
Update API
This commit is contained in:
parent
66d26febc1
commit
ff6b90f4f4
@ -35,28 +35,9 @@ public func availableGroupsForChannelDiscussion(postbox: Postbox, network: Netwo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func availableChannelsForGroupDiscussion(network: Network) -> Signal<[Peer], AvailableChannelDiscussionGroupError> {
|
|
||||||
return network.request(Api.functions.channels.getBroadcastsForDiscussion()) |> mapError { _ in
|
|
||||||
return .generic
|
|
||||||
} |> map { result in
|
|
||||||
let chats:[Api.Chat]
|
|
||||||
switch result {
|
|
||||||
case let .chats(c):
|
|
||||||
chats = c
|
|
||||||
case let .chatsSlice(_, c):
|
|
||||||
chats = c
|
|
||||||
}
|
|
||||||
|
|
||||||
let peers = chats.compactMap {
|
|
||||||
return parseTelegramGroupOrChannel(chat: $0)
|
|
||||||
}
|
|
||||||
|
|
||||||
return peers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ChannelDiscussionGroupError {
|
public enum ChannelDiscussionGroupError {
|
||||||
case generic
|
case generic
|
||||||
|
case groupHistoryIsCurrentlyPrivate
|
||||||
}
|
}
|
||||||
|
|
||||||
public func updateGroupDiscussionForChannel(network: Network, postbox: Postbox, channelId: PeerId, groupId: PeerId?) -> Signal<Bool, ChannelDiscussionGroupError> {
|
public func updateGroupDiscussionForChannel(network: Network, postbox: Postbox, channelId: PeerId, groupId: PeerId?) -> Signal<Bool, ChannelDiscussionGroupError> {
|
||||||
@ -88,6 +69,8 @@ public func updateGroupDiscussionForChannel(network: Network, postbox: Postbox,
|
|||||||
|> `catch` { error -> Signal<Bool, ChannelDiscussionGroupError> in
|
|> `catch` { error -> Signal<Bool, ChannelDiscussionGroupError> in
|
||||||
if error.errorDescription == "LINK_NOT_MODIFIED" {
|
if error.errorDescription == "LINK_NOT_MODIFIED" {
|
||||||
return .single(true)
|
return .single(true)
|
||||||
|
} else if error.errorDescription == "MEGAGROUP_PREHISTORY_HIDDEN" {
|
||||||
|
return .fail(.groupHistoryIsCurrentlyPrivate)
|
||||||
}
|
}
|
||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user