mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
- fulfillStars
- joinchannel method update for paid subscriptions
This commit is contained in:
parent
c504c1d70e
commit
f200b4fd4d
@ -97,5 +97,8 @@ public extension TelegramEngine {
|
||||
public func updateStarsSubscription(peerId: EnginePeer.Id, subscriptionId: String, cancel: Bool) -> Signal<Never, UpdateStarsSubsciptionError> {
|
||||
return _internal_updateStarsSubscription(account: self.account, peerId: peerId, subscriptionId: subscriptionId, cancel: cancel)
|
||||
}
|
||||
public func fulfillStarsSubscription(peerId: PeerId, subscriptionId: String) -> Signal<Never, FulfillStarsSubsciptionError> {
|
||||
return _internal_fulfillStarsSubscription(account: self.account, peerId: peerId, subscriptionId: subscriptionId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,29 +17,35 @@ func _internal_joinChannel(account: Account, peerId: PeerId, hash: String?) -> S
|
||||
|> take(1)
|
||||
|> castError(JoinChannelError.self)
|
||||
|> mapToSignal { peer -> Signal<RenderedChannelParticipant?, JoinChannelError> in
|
||||
if let inputChannel = apiInputChannel(peer) {
|
||||
let request: Signal<Api.Updates, MTRpcError>
|
||||
if let hash = hash {
|
||||
request = account.network.request(Api.functions.messages.importChatInvite(hash: hash))
|
||||
} else {
|
||||
request = account.network.request(Api.functions.channels.joinChannel(channel: inputChannel))
|
||||
|
||||
let request: Signal<Api.Updates, MTRpcError>
|
||||
if let hash = hash {
|
||||
request = account.network.request(Api.functions.messages.importChatInvite(hash: hash))
|
||||
} else if let inputChannel = apiInputChannel(peer) {
|
||||
request = account.network.request(Api.functions.channels.joinChannel(channel: inputChannel))
|
||||
} else {
|
||||
request = .fail(.init())
|
||||
}
|
||||
|
||||
return request
|
||||
|> mapError { error -> JoinChannelError in
|
||||
switch error.errorDescription {
|
||||
case "CHANNELS_TOO_MUCH":
|
||||
return .tooMuchJoined
|
||||
case "USERS_TOO_MUCH":
|
||||
return .tooMuchUsers
|
||||
case "INVITE_REQUEST_SENT":
|
||||
return .inviteRequestSent
|
||||
default:
|
||||
return .generic
|
||||
}
|
||||
return request
|
||||
|> mapError { error -> JoinChannelError in
|
||||
switch error.errorDescription {
|
||||
case "CHANNELS_TOO_MUCH":
|
||||
return .tooMuchJoined
|
||||
case "USERS_TOO_MUCH":
|
||||
return .tooMuchUsers
|
||||
case "INVITE_REQUEST_SENT":
|
||||
return .inviteRequestSent
|
||||
default:
|
||||
return .generic
|
||||
}
|
||||
}
|
||||
|> mapToSignal { updates -> Signal<RenderedChannelParticipant?, JoinChannelError> in
|
||||
account.stateManager.addUpdates(updates)
|
||||
|
||||
}
|
||||
|> mapToSignal { updates -> Signal<RenderedChannelParticipant?, JoinChannelError> in
|
||||
account.stateManager.addUpdates(updates)
|
||||
|
||||
let channels = updates.chats.compactMap { parseTelegramGroupOrChannel(chat: $0) }.compactMap(apiInputChannel)
|
||||
|
||||
if let inputChannel = channels.first {
|
||||
return account.network.request(Api.functions.channels.getParticipant(channel: inputChannel, participant: .inputPeerSelf))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<Api.channels.ChannelParticipant?, JoinChannelError> in
|
||||
@ -76,14 +82,16 @@ func _internal_joinChannel(account: Account, peerId: PeerId, hash: String?) -> S
|
||||
}
|
||||
|> castError(JoinChannelError.self)
|
||||
}
|
||||
} else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
|> afterCompleted {
|
||||
if hash == nil {
|
||||
let _ = _internal_requestRecommendedChannels(account: account, peerId: peerId, forceUpdate: true).startStandalone()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|> afterCompleted {
|
||||
if hash == nil {
|
||||
let _ = _internal_requestRecommendedChannels(account: account, peerId: peerId, forceUpdate: true).startStandalone()
|
||||
}
|
||||
} else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user