Update API

This commit is contained in:
Ilya Laktyushin
2021-11-03 00:44:41 +04:00
parent 9daed68d53
commit 7b3d1c6f59
14 changed files with 178 additions and 1 deletions

View File

@@ -0,0 +1,17 @@
import Foundation
import Postbox
import SwiftSignalKit
import TelegramApi
import MtProtoKit
func _internal_toggleChannelMessageCopyProtection(account:Account, peerId:PeerId, enabled: Bool) -> Signal<Void, NoError> {
return account.postbox.transaction { transaction -> Signal<Void, NoError> in
if let peer = transaction.getPeer(peerId) as? TelegramChannel, let inputChannel = apiInputChannel(peer) {
return account.network.request(Api.functions.channels.toggleNoForwards(channel: inputChannel, enabled: enabled ? .boolTrue : .boolFalse)) |> retryRequest |> map { updates -> Void in
account.stateManager.addUpdates(updates)
}
} else {
return .complete()
}
} |> switchToLatest
}