mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Merge commit 'aa21a14c7d'
# Conflicts: # submodules/TelegramUI/Components/ContextControllerImpl/Sources/ContextActionsContainerNode.swift
This commit is contained in:
commit
a3b4b085ae
15 changed files with 166 additions and 78 deletions
|
|
@ -5439,14 +5439,23 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||
})
|
||||
}
|
||||
|
||||
if let self, case let .channel(channel) = peer.peer, channel.flags.contains(.isCreator) {
|
||||
let _ = (self.context.engine.peers.getFutureCreatorAfterLeave(peerId: channel.id)
|
||||
let shouldCheckFutureCreator: Bool
|
||||
if case let .channel(channel) = peer.peer, channel.flags.contains(.isCreator) {
|
||||
shouldCheckFutureCreator = true
|
||||
} else if case let .legacyGroup(group) = peer.peer, case .creator = group.role {
|
||||
shouldCheckFutureCreator = true
|
||||
} else {
|
||||
shouldCheckFutureCreator = false
|
||||
}
|
||||
|
||||
if let self, shouldCheckFutureCreator {
|
||||
let _ = (self.context.engine.peers.getFutureCreatorAfterLeave(peerId: peer.peerId)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] nextCreator in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if let nextCreator, let peer = peer.peer {
|
||||
self.presentLeaveChannelConfirmation(peer: peer, nextCreator: nextCreator, completion: { commit in
|
||||
self.presentLeaveChatConfirmation(peer: peer, nextCreator: nextCreator, completion: { commit in
|
||||
if commit {
|
||||
proceed()
|
||||
}
|
||||
|
|
@ -5913,14 +5922,24 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||
removed()
|
||||
})
|
||||
}
|
||||
|
||||
let shouldCheckFutureCreator: Bool
|
||||
if case let .channel(channel) = peer.peer, channel.flags.contains(.isCreator) {
|
||||
let _ = (self.context.engine.peers.getFutureCreatorAfterLeave(peerId: channel.id)
|
||||
shouldCheckFutureCreator = true
|
||||
} else if case let .legacyGroup(group) = peer.peer, case .creator = group.role {
|
||||
shouldCheckFutureCreator = true
|
||||
} else {
|
||||
shouldCheckFutureCreator = false
|
||||
}
|
||||
|
||||
if shouldCheckFutureCreator {
|
||||
let _ = (self.context.engine.peers.getFutureCreatorAfterLeave(peerId: peer.peerId)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] nextCreator in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if let nextCreator, let peer = peer.peer {
|
||||
self.presentLeaveChannelConfirmation(peer: peer, nextCreator: nextCreator, completion: { commit in
|
||||
self.presentLeaveChatConfirmation(peer: peer, nextCreator: nextCreator, completion: { commit in
|
||||
if commit {
|
||||
proceed()
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import PeerInfoUI
|
|||
import OwnershipTransferController
|
||||
|
||||
extension ChatListControllerImpl {
|
||||
func presentLeaveChannelConfirmation(peer: EnginePeer, nextCreator: EnginePeer, completion: @escaping (Bool) -> Void) {
|
||||
func presentLeaveChatConfirmation(peer: EnginePeer, nextCreator: EnginePeer, completion: @escaping (Bool) -> Void) {
|
||||
Task { @MainActor in
|
||||
let accountPeer = await (self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: self.context.account.peerId))).get()
|
||||
|
||||
|
|
@ -1172,6 +1172,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||
dict[-1094555409] = { return Api.Update.parse_updateNotifySettings($0) }
|
||||
dict[-1955438642] = { return Api.Update.parse_updatePaidReactionPrivacy($0) }
|
||||
dict[-337610926] = { return Api.Update.parse_updatePeerBlocked($0) }
|
||||
dict[1115654513] = { return Api.Update.parse_updatePeerHistoryNoForward($0) }
|
||||
dict[-1147422299] = { return Api.Update.parse_updatePeerHistoryTTL($0) }
|
||||
dict[-1263546448] = { return Api.Update.parse_updatePeerLocated($0) }
|
||||
dict[1786671974] = { return Api.Update.parse_updatePeerSettings($0) }
|
||||
|
|
|
|||
|
|
@ -969,6 +969,14 @@ public extension Api {
|
|||
self.peerId = peerId
|
||||
}
|
||||
}
|
||||
public class Cons_updatePeerHistoryNoForward {
|
||||
public var flags: Int32
|
||||
public var peer: Api.Peer
|
||||
public init(flags: Int32, peer: Api.Peer) {
|
||||
self.flags = flags
|
||||
self.peer = peer
|
||||
}
|
||||
}
|
||||
public class Cons_updatePeerHistoryTTL {
|
||||
public var flags: Int32
|
||||
public var peer: Api.Peer
|
||||
|
|
@ -1531,6 +1539,7 @@ public extension Api {
|
|||
case updateNotifySettings(Cons_updateNotifySettings)
|
||||
case updatePaidReactionPrivacy(Cons_updatePaidReactionPrivacy)
|
||||
case updatePeerBlocked(Cons_updatePeerBlocked)
|
||||
case updatePeerHistoryNoForward(Cons_updatePeerHistoryNoForward)
|
||||
case updatePeerHistoryTTL(Cons_updatePeerHistoryTTL)
|
||||
case updatePeerLocated(Cons_updatePeerLocated)
|
||||
case updatePeerSettings(Cons_updatePeerSettings)
|
||||
|
|
@ -2488,6 +2497,13 @@ public extension Api {
|
|||
serializeInt32(_data.flags, buffer: buffer, boxed: false)
|
||||
_data.peerId.serialize(buffer, true)
|
||||
break
|
||||
case .updatePeerHistoryNoForward(let _data):
|
||||
if boxed {
|
||||
buffer.appendInt32(1115654513)
|
||||
}
|
||||
serializeInt32(_data.flags, buffer: buffer, boxed: false)
|
||||
_data.peer.serialize(buffer, true)
|
||||
break
|
||||
case .updatePeerHistoryTTL(let _data):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1147422299)
|
||||
|
|
@ -3192,6 +3208,8 @@ public extension Api {
|
|||
return ("updatePaidReactionPrivacy", [("`private`", _data.`private` as Any)])
|
||||
case .updatePeerBlocked(let _data):
|
||||
return ("updatePeerBlocked", [("flags", _data.flags as Any), ("peerId", _data.peerId as Any)])
|
||||
case .updatePeerHistoryNoForward(let _data):
|
||||
return ("updatePeerHistoryNoForward", [("flags", _data.flags as Any), ("peer", _data.peer as Any)])
|
||||
case .updatePeerHistoryTTL(let _data):
|
||||
return ("updatePeerHistoryTTL", [("flags", _data.flags as Any), ("peer", _data.peer as Any), ("ttlPeriod", _data.ttlPeriod as Any)])
|
||||
case .updatePeerLocated(let _data):
|
||||
|
|
@ -5158,6 +5176,22 @@ public extension Api {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_updatePeerHistoryNoForward(_ reader: BufferReader) -> Update? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Api.Peer?
|
||||
if let signature = reader.readInt32() {
|
||||
_2 = Api.parse(reader, signature: signature) as? Api.Peer
|
||||
}
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
if _c1 && _c2 {
|
||||
return Api.Update.updatePeerHistoryNoForward(Cons_updatePeerHistoryNoForward(flags: _1!, peer: _2!))
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_updatePeerHistoryTTL(_ reader: BufferReader) -> Update? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
|
|
|
|||
|
|
@ -3191,23 +3191,6 @@ public extension Api.functions.channels {
|
|||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.channels {
|
||||
static func editCreator(channel: Api.InputChannel, userId: Api.InputUser, password: Api.InputCheckPasswordSRP) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-1892102881)
|
||||
channel.serialize(buffer, true)
|
||||
userId.serialize(buffer, true)
|
||||
password.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "channels.editCreator", parameters: [("channel", String(describing: channel)), ("userId", String(describing: userId)), ("password", String(describing: password))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Updates?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Updates
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.channels {
|
||||
static func editLocation(channel: Api.InputChannel, geoPoint: Api.InputGeoPoint, address: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
|
|
@ -3371,21 +3354,6 @@ public extension Api.functions.channels {
|
|||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.channels {
|
||||
static func getFutureCreatorAfterLeave(channel: Api.InputChannel) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.User>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-1610016593)
|
||||
channel.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "channels.getFutureCreatorAfterLeave", parameters: [("channel", String(describing: channel))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.User? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.User?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.User
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.channels {
|
||||
static func getGroupsForDiscussion() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.Chats>) {
|
||||
let buffer = Buffer()
|
||||
|
|
@ -5742,6 +5710,23 @@ public extension Api.functions.messages {
|
|||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func editChatCreator(peer: Api.InputPeer, userId: Api.InputUser, password: Api.InputCheckPasswordSRP) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-146556841)
|
||||
peer.serialize(buffer, true)
|
||||
userId.serialize(buffer, true)
|
||||
password.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "messages.editChatCreator", parameters: [("peer", String(describing: peer)), ("userId", String(describing: userId)), ("password", String(describing: password))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Updates?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Updates
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func editChatDefaultBannedRights(peer: Api.InputPeer, bannedRights: Api.ChatBannedRights) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
|
|
@ -6781,6 +6766,21 @@ public extension Api.functions.messages {
|
|||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func getFutureChatCreatorAfterLeave(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.User>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(998051494)
|
||||
peer.serialize(buffer, true)
|
||||
return (FunctionDescription(name: "messages.getFutureChatCreatorAfterLeave", parameters: [("peer", String(describing: peer))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.User? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.User?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.User
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.messages {
|
||||
static func getGameHighScores(peer: Api.InputPeer, id: Int32, userId: Api.InputUser) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.HighScores>) {
|
||||
let buffer = Buffer()
|
||||
|
|
|
|||
|
|
@ -2010,6 +2010,26 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
|
|||
updatedState.updateStarGiftAuctionMyState(giftId: giftId, state: GiftAuctionContext.State.MyState(apiAuctionUserState: userState))
|
||||
case let .updateEmojiGameInfo(updateEmojiGameInfoData):
|
||||
updatedState.updateEmojiGameInfo(info: EmojiGameInfo(apiEmojiGameInfo: updateEmojiGameInfoData.info))
|
||||
case let .updatePeerHistoryNoForward(updatePeerHistoryNoForwardData):
|
||||
let (flags, peer) = (updatePeerHistoryNoForwardData.flags, updatePeerHistoryNoForwardData.peer)
|
||||
let peerId = peer.peerId
|
||||
updatedState.updateCachedPeerData(peerId, { current in
|
||||
if let previous = current as? CachedUserData {
|
||||
var updatedFlags = previous.flags
|
||||
if (flags & (1 << 0)) != 0 {
|
||||
updatedFlags.insert(.myCopyProtectionEnabled)
|
||||
} else {
|
||||
updatedFlags.remove(.myCopyProtectionEnabled)
|
||||
}
|
||||
if (flags & (1 << 1)) != 0 {
|
||||
updatedFlags.insert(.copyProtectionEnabled)
|
||||
} else {
|
||||
updatedFlags.remove(.copyProtectionEnabled)
|
||||
}
|
||||
return previous.withUpdatedFlags(updatedFlags)
|
||||
}
|
||||
return current
|
||||
})
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
|
|||
|
||||
public class Serialization: NSObject, MTSerialization {
|
||||
public func currentLayer() -> UInt {
|
||||
return 222
|
||||
return 223
|
||||
}
|
||||
|
||||
public func parseMessage(_ data: Data!) -> Any! {
|
||||
|
|
|
|||
|
|
@ -627,6 +627,8 @@ public struct CachedUserFlags: OptionSet {
|
|||
public static let canViewRevenue = CachedUserFlags(rawValue: 1 << 5)
|
||||
public static let botCanManageEmojiStatus = CachedUserFlags(rawValue: 1 << 6)
|
||||
public static let displayGiftButton = CachedUserFlags(rawValue: 1 << 7)
|
||||
public static let myCopyProtectionEnabled = CachedUserFlags(rawValue: 1 << 8)
|
||||
public static let copyProtectionEnabled = CachedUserFlags(rawValue: 1 << 9)
|
||||
}
|
||||
|
||||
public final class EditableBotInfo: PostboxCoding, Equatable {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import Postbox
|
|||
import TelegramApi
|
||||
|
||||
|
||||
public enum ChannelOwnershipTransferError {
|
||||
public enum ChatOwnershipTransferError {
|
||||
case generic
|
||||
case twoStepAuthMissing
|
||||
case twoStepAuthTooFresh(Int32)
|
||||
|
|
@ -20,12 +20,12 @@ public enum ChannelOwnershipTransferError {
|
|||
case userBlocked
|
||||
}
|
||||
|
||||
func _internal_checkOwnershipTranfserAvailability(postbox: Postbox, network: Network, accountStateManager: AccountStateManager, memberId: PeerId) -> Signal<Never, ChannelOwnershipTransferError> {
|
||||
func _internal_checkOwnershipTranfserAvailability(postbox: Postbox, network: Network, accountStateManager: AccountStateManager, memberId: PeerId) -> Signal<Never, ChatOwnershipTransferError> {
|
||||
return postbox.transaction { transaction -> Peer? in
|
||||
return transaction.getPeer(memberId)
|
||||
}
|
||||
|> castError(ChannelOwnershipTransferError.self)
|
||||
|> mapToSignal { user -> Signal<Never, ChannelOwnershipTransferError> in
|
||||
|> castError(ChatOwnershipTransferError.self)
|
||||
|> mapToSignal { user -> Signal<Never, ChatOwnershipTransferError> in
|
||||
guard let user = user else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
|
|
@ -33,8 +33,8 @@ func _internal_checkOwnershipTranfserAvailability(postbox: Postbox, network: Net
|
|||
return .fail(.generic)
|
||||
}
|
||||
|
||||
return network.request(Api.functions.channels.editCreator(channel: .inputChannelEmpty, userId: apiUser, password: .inputCheckPasswordEmpty))
|
||||
|> mapError { error -> ChannelOwnershipTransferError in
|
||||
return network.request(Api.functions.messages.editChatCreator(peer: .inputPeerEmpty, userId: apiUser, password: .inputCheckPasswordEmpty))
|
||||
|> mapError { error -> ChatOwnershipTransferError in
|
||||
if error.errorDescription == "PASSWORD_HASH_INVALID" {
|
||||
return .requestPassword
|
||||
} else if error.errorDescription == "PASSWORD_MISSING" {
|
||||
|
|
@ -64,39 +64,39 @@ func _internal_checkOwnershipTranfserAvailability(postbox: Postbox, network: Net
|
|||
}
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { updates -> Signal<Never, ChannelOwnershipTransferError> in
|
||||
|> mapToSignal { updates -> Signal<Never, ChatOwnershipTransferError> in
|
||||
accountStateManager.addUpdates(updates)
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_updateChannelOwnership(account: Account, channelId: PeerId, memberId: PeerId, password: String) -> Signal<[(ChannelParticipant?, RenderedChannelParticipant)], ChannelOwnershipTransferError> {
|
||||
func _internal_updateChatOwnership(account: Account, peerId: PeerId, memberId: PeerId, password: String) -> Signal<[(ChannelParticipant?, RenderedChannelParticipant)], ChatOwnershipTransferError> {
|
||||
guard !password.isEmpty else {
|
||||
return .fail(.invalidPassword)
|
||||
}
|
||||
|
||||
return combineLatest(_internal_fetchChannelParticipant(account: account, peerId: channelId, participantId: account.peerId), _internal_fetchChannelParticipant(account: account, peerId: channelId, participantId: memberId))
|
||||
|> mapError { _ -> ChannelOwnershipTransferError in
|
||||
return combineLatest(_internal_fetchChannelParticipant(account: account, peerId: peerId, participantId: account.peerId), _internal_fetchChannelParticipant(account: account, peerId: peerId, participantId: memberId))
|
||||
|> mapError { _ -> ChatOwnershipTransferError in
|
||||
}
|
||||
|> mapToSignal { currentCreator, currentParticipant -> Signal<[(ChannelParticipant?, RenderedChannelParticipant)], ChannelOwnershipTransferError> in
|
||||
return account.postbox.transaction { transaction -> Signal<[(ChannelParticipant?, RenderedChannelParticipant)], ChannelOwnershipTransferError> in
|
||||
if let channel = transaction.getPeer(channelId) as? TelegramChannel, let inputChannel = apiInputChannel(channel), let accountUser = transaction.getPeer(account.peerId), let user = transaction.getPeer(memberId), let inputUser = apiInputUser(user) {
|
||||
|> mapToSignal { currentCreator, currentParticipant -> Signal<[(ChannelParticipant?, RenderedChannelParticipant)], ChatOwnershipTransferError> in
|
||||
return account.postbox.transaction { transaction -> Signal<[(ChannelParticipant?, RenderedChannelParticipant)], ChatOwnershipTransferError> in
|
||||
if let peer = transaction.getPeer(peerId), let inputPeer = apiInputPeer(peer), let accountUser = transaction.getPeer(account.peerId), let user = transaction.getPeer(memberId), let inputUser = apiInputUser(user) {
|
||||
|
||||
let flags: TelegramChatAdminRightsFlags = TelegramChatAdminRightsFlags.peerSpecific(peer: .channel(channel))
|
||||
let flags: TelegramChatAdminRightsFlags = TelegramChatAdminRightsFlags.peerSpecific(peer: EnginePeer(peer))
|
||||
|
||||
let updatedParticipant = ChannelParticipant.creator(id: user.id, adminInfo: nil, rank: currentParticipant?.rank)
|
||||
let updatedPreviousCreator = ChannelParticipant.member(id: accountUser.id, invitedAt: Int32(Date().timeIntervalSince1970), adminInfo: ChannelParticipantAdminInfo(rights: TelegramChatAdminRights(rights: flags), promotedBy: accountUser.id, canBeEditedByAccountPeer: false), banInfo: nil, rank: currentCreator?.rank, subscriptionUntilDate: nil)
|
||||
|
||||
let checkPassword = _internal_twoStepAuthData(account.network)
|
||||
|> mapError { error -> ChannelOwnershipTransferError in
|
||||
|> mapError { error -> ChatOwnershipTransferError in
|
||||
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||
return .limitExceeded
|
||||
} else {
|
||||
return .generic
|
||||
}
|
||||
}
|
||||
|> mapToSignal { authData -> Signal<Api.InputCheckPasswordSRP, ChannelOwnershipTransferError> in
|
||||
|> mapToSignal { authData -> Signal<Api.InputCheckPasswordSRP, ChatOwnershipTransferError> in
|
||||
if let currentPasswordDerivation = authData.currentPasswordDerivation, let srpSessionData = authData.srpSessionData {
|
||||
guard let kdfResult = passwordKDF(encryptionProvider: account.network.encryptionProvider, password: password, derivation: currentPasswordDerivation, srpSessionData: srpSessionData) else {
|
||||
return .fail(.generic)
|
||||
|
|
@ -108,9 +108,9 @@ func _internal_updateChannelOwnership(account: Account, channelId: PeerId, membe
|
|||
}
|
||||
|
||||
return checkPassword
|
||||
|> mapToSignal { password -> Signal<[(ChannelParticipant?, RenderedChannelParticipant)], ChannelOwnershipTransferError> in
|
||||
return account.network.request(Api.functions.channels.editCreator(channel: inputChannel, userId: inputUser, password: password), automaticFloodWait: false)
|
||||
|> mapError { error -> ChannelOwnershipTransferError in
|
||||
|> mapToSignal { password -> Signal<[(ChannelParticipant?, RenderedChannelParticipant)], ChatOwnershipTransferError> in
|
||||
return account.network.request(Api.functions.messages.editChatCreator(peer: inputPeer, userId: inputUser, password: password), automaticFloodWait: false)
|
||||
|> mapError { error -> ChatOwnershipTransferError in
|
||||
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||
return .limitExceeded
|
||||
} else if error.errorDescription == "PASSWORD_HASH_INVALID" {
|
||||
|
|
@ -140,11 +140,11 @@ func _internal_updateChannelOwnership(account: Account, channelId: PeerId, membe
|
|||
}
|
||||
return .generic
|
||||
}
|
||||
|> mapToSignal { updates -> Signal<[(ChannelParticipant?, RenderedChannelParticipant)], ChannelOwnershipTransferError> in
|
||||
|> mapToSignal { updates -> Signal<[(ChannelParticipant?, RenderedChannelParticipant)], ChatOwnershipTransferError> in
|
||||
account.stateManager.addUpdates(updates)
|
||||
|
||||
return account.postbox.transaction { transaction -> [(ChannelParticipant?, RenderedChannelParticipant)] in
|
||||
transaction.updatePeerCachedData(peerIds: Set([channelId]), update: { _, cachedData -> CachedPeerData? in
|
||||
transaction.updatePeerCachedData(peerIds: Set([peerId]), update: { _, cachedData -> CachedPeerData? in
|
||||
if let cachedData = cachedData as? CachedChannelData, let adminCount = cachedData.participantsSummary.adminCount {
|
||||
var updatedAdminCount = adminCount
|
||||
var wasAdmin = false
|
||||
|
|
@ -179,14 +179,14 @@ func _internal_updateChannelOwnership(account: Account, channelId: PeerId, membe
|
|||
}
|
||||
return [(currentCreator, RenderedChannelParticipant(participant: updatedPreviousCreator, peer: accountUser, peers: peers, presences: presences)), (currentParticipant, RenderedChannelParticipant(participant: updatedParticipant, peer: user, peers: peers, presences: presences))]
|
||||
}
|
||||
|> mapError { _ -> ChannelOwnershipTransferError in }
|
||||
|> mapError { _ -> ChatOwnershipTransferError in }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
}
|
||||
|> mapError { _ -> ChannelOwnershipTransferError in }
|
||||
|> mapError { _ -> ChatOwnershipTransferError in }
|
||||
|> switchToLatest
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,13 +83,13 @@ func _internal_removePeerChat(account: Account, transaction: Transaction, mediaB
|
|||
|
||||
func _internal_getFutureCreatorAfterLeave(account: Account, peerId: EnginePeer.Id) -> Signal<EnginePeer?, NoError> {
|
||||
return account.postbox.transaction { transaction in
|
||||
return transaction.getPeer(peerId).flatMap(apiInputChannel)
|
||||
return transaction.getPeer(peerId).flatMap(apiInputPeer)
|
||||
}
|
||||
|> mapToSignal { channel in
|
||||
guard let channel else {
|
||||
|> mapToSignal { peer in
|
||||
guard let peer else {
|
||||
return .single(nil)
|
||||
}
|
||||
return account.network.request(Api.functions.channels.getFutureCreatorAfterLeave(channel: channel))
|
||||
return account.network.request(Api.functions.messages.getFutureChatCreatorAfterLeave(peer: peer))
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ in
|
||||
return .single(nil)
|
||||
|
|
|
|||
|
|
@ -486,12 +486,12 @@ public extension TelegramEngine {
|
|||
return _internal_channelMembers(postbox: self.account.postbox, network: self.account.network, accountPeerId: self.account.peerId, peerId: peerId, category: category, offset: offset, limit: limit, hash: hash)
|
||||
}
|
||||
|
||||
public func checkOwnershipTranfserAvailability(memberId: PeerId) -> Signal<Never, ChannelOwnershipTransferError> {
|
||||
public func checkOwnershipTranfserAvailability(memberId: PeerId) -> Signal<Never, ChatOwnershipTransferError> {
|
||||
return _internal_checkOwnershipTranfserAvailability(postbox: self.account.postbox, network: self.account.network, accountStateManager: self.account.stateManager, memberId: memberId)
|
||||
}
|
||||
|
||||
public func updateChannelOwnership(channelId: PeerId, memberId: PeerId, password: String) -> Signal<[(ChannelParticipant?, RenderedChannelParticipant)], ChannelOwnershipTransferError> {
|
||||
return _internal_updateChannelOwnership(account: self.account, channelId: channelId, memberId: memberId, password: password)
|
||||
public func updateChatOwnership(peerId: PeerId, memberId: PeerId, password: String) -> Signal<[(ChannelParticipant?, RenderedChannelParticipant)], ChatOwnershipTransferError> {
|
||||
return _internal_updateChatOwnership(account: self.account, peerId: peerId, memberId: memberId, password: password)
|
||||
}
|
||||
|
||||
public func searchGroupMembers(peerId: PeerId, query: String) -> Signal<[EnginePeer], NoError> {
|
||||
|
|
|
|||
|
|
@ -297,6 +297,8 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee
|
|||
let canViewRevenue = (userFullFlags2 & (1 << 9)) != 0
|
||||
let botCanManageEmojiStatus = (userFullFlags2 & (1 << 10)) != 0
|
||||
let displayGiftButton = (userFullFlags2 & (1 << 16)) != 0
|
||||
let myCopyProtectionEnabled = (userFullFlags2 & (1 << 23)) != 0
|
||||
let copyProtectionEnabled = (userFullFlags2 & (1 << 24)) != 0
|
||||
|
||||
var flags: CachedUserFlags = previous.flags
|
||||
if premiumRequired {
|
||||
|
|
@ -334,6 +336,16 @@ func _internal_fetchAndUpdateCachedPeerData(accountPeerId: PeerId, peerId rawPee
|
|||
} else {
|
||||
flags.remove(.displayGiftButton)
|
||||
}
|
||||
if myCopyProtectionEnabled {
|
||||
flags.insert(.myCopyProtectionEnabled)
|
||||
} else {
|
||||
flags.remove(.myCopyProtectionEnabled)
|
||||
}
|
||||
if copyProtectionEnabled {
|
||||
flags.insert(.copyProtectionEnabled)
|
||||
} else {
|
||||
flags.remove(.copyProtectionEnabled)
|
||||
}
|
||||
|
||||
let callsPrivate = (userFullFlags & (1 << 5)) != 0
|
||||
let canPinMessages = (userFullFlags & (1 << 7)) != 0
|
||||
|
|
|
|||
|
|
@ -3521,9 +3521,9 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
|
|||
},
|
||||
mosaicStatusOrigin: mosaicStatusOrigin,
|
||||
mosaicStatusSizeAndApply: mosaicStatusSizeAndApply,
|
||||
unlockButtonPosition: unlockButtonPosition?.offsetBy(dx: 0.0, dy: layoutInsets.top),
|
||||
unlockButtonPosition: unlockButtonPosition,
|
||||
unlockButtonSizeAndApply: unlockButtonSizeApply,
|
||||
mediaInfoOrigin: mediaInfoOrigin?.offsetBy(dx: 0.0, dy: layoutInsets.top),
|
||||
mediaInfoOrigin: mediaInfoOrigin,
|
||||
mediaInfoSizeAndApply: mediaInfoSizeApply,
|
||||
needsSummarizeButton: needsSummarizeButton,
|
||||
needsShareButton: needsShareButton,
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ private func commitChannelOwnershipTransferController(
|
|||
applyImpl = {
|
||||
doneInProgressPromise.set(true)
|
||||
|
||||
let signal: Signal<EnginePeer.Id?, ChannelOwnershipTransferError>
|
||||
let signal: Signal<EnginePeer.Id?, ChatOwnershipTransferError>
|
||||
if case let .channel(peer) = peer {
|
||||
signal = context.peerChannelMemberCategoriesContextsManager.transferOwnership(engine: context.engine, peerId: peer.id, memberId: member.id, password: inputState.value) |> mapToSignal { _ in
|
||||
return .complete()
|
||||
|
|
@ -97,7 +97,7 @@ private func commitChannelOwnershipTransferController(
|
|||
} else if case let .legacyGroup(peer) = peer {
|
||||
signal = context.engine.peers.convertGroupToSupergroup(peerId: peer.id)
|
||||
|> map(Optional.init)
|
||||
|> mapError { error -> ChannelOwnershipTransferError in
|
||||
|> mapError { error -> ChatOwnershipTransferError in
|
||||
switch error {
|
||||
case .tooManyChannels:
|
||||
return .tooMuchJoined
|
||||
|
|
@ -106,7 +106,7 @@ private func commitChannelOwnershipTransferController(
|
|||
}
|
||||
}
|
||||
|> deliverOnMainQueue
|
||||
|> mapToSignal { upgradedPeerId -> Signal<EnginePeer.Id?, ChannelOwnershipTransferError> in
|
||||
|> mapToSignal { upgradedPeerId -> Signal<EnginePeer.Id?, ChatOwnershipTransferError> in
|
||||
guard let upgradedPeerId = upgradedPeerId else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
|
|
@ -213,7 +213,7 @@ public func channelOwnershipTransferController(
|
|||
peer: EnginePeer,
|
||||
member: TelegramUser,
|
||||
onLeave: Bool,
|
||||
initialError: ChannelOwnershipTransferError,
|
||||
initialError: ChatOwnershipTransferError,
|
||||
present: @escaping (ViewController, Any?) -> Void,
|
||||
push: @escaping (ViewController) -> Void,
|
||||
completion: @escaping (EnginePeer.Id?) -> Void
|
||||
|
|
|
|||
|
|
@ -408,8 +408,8 @@ public final class PeerChannelMemberCategoriesContextsManager {
|
|||
}
|
||||
}
|
||||
|
||||
public func transferOwnership(engine: TelegramEngine, peerId: PeerId, memberId: PeerId, password: String) -> Signal<Void, ChannelOwnershipTransferError> {
|
||||
return engine.peers.updateChannelOwnership(channelId: peerId, memberId: memberId, password: password)
|
||||
public func transferOwnership(engine: TelegramEngine, peerId: PeerId, memberId: PeerId, password: String) -> Signal<Void, ChatOwnershipTransferError> {
|
||||
return engine.peers.updateChatOwnership(peerId: peerId, memberId: memberId, password: password)
|
||||
|> map(Optional.init)
|
||||
|> deliverOnMainQueue
|
||||
|> beforeNext { [weak self] results in
|
||||
|
|
@ -423,7 +423,7 @@ public final class PeerChannelMemberCategoriesContextsManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|> mapToSignal { _ -> Signal<Void, ChannelOwnershipTransferError> in
|
||||
|> mapToSignal { _ -> Signal<Void, ChatOwnershipTransferError> in
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue