Update API

This commit is contained in:
Peter 2019-05-29 21:30:03 +02:00
parent 66d26febc1
commit ff6b90f4f4

View File

@ -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 {
case generic
case groupHistoryIsCurrentlyPrivate
}
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
if error.errorDescription == "LINK_NOT_MODIFIED" {
return .single(true)
} else if error.errorDescription == "MEGAGROUP_PREHISTORY_HIDDEN" {
return .fail(.groupHistoryIsCurrentlyPrivate)
}
return .fail(.generic)
}