diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 6c71dc1d97..91c7cd7a05 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -12672,3 +12672,6 @@ Sorry for the inconvenience."; "Stars.Intro.GiftStars" = "Gift Stars to Friends"; "MediaPicker.CreateSticker" = "Create a sticker from a photo"; + +"Channel.AdminLog.MessageToggleProfileSignaturesOn" = "%@ enabled admin profiles"; +"Channel.AdminLog.MessageToggleProfileSignaturesOff" = "%@ disabled admin profiles"; diff --git a/submodules/PeerInfoUI/Sources/ChannelAdminsController.swift b/submodules/PeerInfoUI/Sources/ChannelAdminsController.swift index 429784f087..e967b8901a 100644 --- a/submodules/PeerInfoUI/Sources/ChannelAdminsController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelAdminsController.swift @@ -24,10 +24,9 @@ private final class ChannelAdminsControllerArguments { let addAdmin: () -> Void let openAdmin: (ChannelParticipant) -> Void let updateAntiSpamEnabled: (Bool) -> Void - let updateSignMessagesEnabled: (Bool) -> Void - let updateShowAuthorProfilesEnabled: (Bool) -> Void + let updateSignaturesAndProfilesEnabled: (Bool, Bool) -> Void - init(context: AccountContext, openRecentActions: @escaping () -> Void, setPeerIdWithRevealedOptions: @escaping (EnginePeer.Id?, EnginePeer.Id?) -> Void, removeAdmin: @escaping (EnginePeer.Id) -> Void, addAdmin: @escaping () -> Void, openAdmin: @escaping (ChannelParticipant) -> Void, updateAntiSpamEnabled: @escaping (Bool) -> Void, updateSignMessagesEnabled: @escaping (Bool) -> Void, updateShowAuthorProfilesEnabled: @escaping (Bool) -> Void) { + init(context: AccountContext, openRecentActions: @escaping () -> Void, setPeerIdWithRevealedOptions: @escaping (EnginePeer.Id?, EnginePeer.Id?) -> Void, removeAdmin: @escaping (EnginePeer.Id) -> Void, addAdmin: @escaping () -> Void, openAdmin: @escaping (ChannelParticipant) -> Void, updateAntiSpamEnabled: @escaping (Bool) -> Void, updateSignaturesAndProfilesEnabled: @escaping (Bool, Bool) -> Void) { self.context = context self.openRecentActions = openRecentActions self.setPeerIdWithRevealedOptions = setPeerIdWithRevealedOptions @@ -35,8 +34,7 @@ private final class ChannelAdminsControllerArguments { self.addAdmin = addAdmin self.openAdmin = openAdmin self.updateAntiSpamEnabled = updateAntiSpamEnabled - self.updateSignMessagesEnabled = updateSignMessagesEnabled - self.updateShowAuthorProfilesEnabled = updateShowAuthorProfilesEnabled + self.updateSignaturesAndProfilesEnabled = updateSignaturesAndProfilesEnabled } } @@ -61,8 +59,8 @@ private enum ChannelAdminsEntry: ItemListNodeEntry { case addAdmin(PresentationTheme, String, Bool) case adminsInfo(PresentationTheme, String) - case signMessages(PresentationTheme, String, Bool) - case showAuthorProfiles(PresentationTheme, String, Bool) + case signMessages(PresentationTheme, String, Bool, Bool) + case showAuthorProfiles(PresentationTheme, String, Bool, Bool) case signMessagesInfo(PresentationTheme, String) var section: ItemListSectionId { @@ -175,14 +173,14 @@ private enum ChannelAdminsEntry: ItemListNodeEntry { } else { return false } - case let .signMessages(lhsTheme, lhsText, lhsValue): - if case let .signMessages(rhsTheme, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue { + case let .signMessages(lhsTheme, lhsText, lhsValue, lhsOtherValue): + if case let .signMessages(rhsTheme, rhsText, rhsValue, rhsOtherValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue, lhsOtherValue == rhsOtherValue { return true } else { return false } - case let .showAuthorProfiles(lhsTheme, lhsText, lhsValue): - if case let .showAuthorProfiles(rhsTheme, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue { + case let .showAuthorProfiles(lhsTheme, lhsText, lhsValue, lhsOtherValue): + if case let .showAuthorProfiles(rhsTheme, rhsText, rhsValue, rhsOtherValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue, lhsOtherValue == rhsOtherValue { return true } else { return false @@ -315,13 +313,13 @@ private enum ChannelAdminsEntry: ItemListNodeEntry { }) case let .adminsInfo(_, text): return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section) - case let .signMessages(_, text, value): + case let .signMessages(_, text, value, profiles): return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, sectionId: self.section, style: .blocks, updated: { value in - arguments.updateSignMessagesEnabled(value) + arguments.updateSignaturesAndProfilesEnabled(value, profiles) }) - case let .showAuthorProfiles(_, text, value): + case let .showAuthorProfiles(_, text, value, signatures): return ItemListSwitchItem(presentationData: presentationData, title: text, value: value, sectionId: self.section, style: .blocks, updated: { value in - arguments.updateShowAuthorProfilesEnabled(value) + arguments.updateSignaturesAndProfilesEnabled(signatures, value) }) case let .signMessagesInfo(_, text): return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section) @@ -497,9 +495,9 @@ private func channelAdminsControllerEntries(presentationData: PresentationData, } if !isGroup && peer.hasPermission(.sendSomething) { - entries.append(.signMessages(presentationData.theme, presentationData.strings.Channel_SignMessages, signMessagesEnabled)) + entries.append(.signMessages(presentationData.theme, presentationData.strings.Channel_SignMessages, signMessagesEnabled, showAuthorProfilesEnabled)) //TODO:localize - entries.append(.showAuthorProfiles(presentationData.theme, "Show Authors' Profiles", showAuthorProfilesEnabled)) + entries.append(.showAuthorProfiles(presentationData.theme, "Show Authors' Profiles", showAuthorProfilesEnabled, signMessagesEnabled)) entries.append(.signMessagesInfo(presentationData.theme, "Add names and photos of admins to the messages they post, linking to their profiles.")) } } @@ -612,9 +610,6 @@ public func channelAdminsController(context: AccountContext, updatedPresentation let updateSignMessagesDisposable = MetaDisposable() actionsDisposable.add(updateSignMessagesDisposable) - let updateShowAuthorProfilesDisposable = MetaDisposable() - actionsDisposable.add(updateShowAuthorProfilesDisposable) - let adminsPromise = Promise<[RenderedChannelParticipant]?>(nil) let antiSpamConfiguration = AntiSpamBotConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 }) @@ -811,17 +806,11 @@ public func channelAdminsController(context: AccountContext, updatedPresentation |> deliverOnMainQueue).start(next: { peerId in updateAntiSpamDisposable.set(context.engine.peers.toggleAntiSpamProtection(peerId: peerId, enabled: value).start()) }) - }, updateSignMessagesEnabled: { value in + }, updateSignaturesAndProfilesEnabled: { signatures, profiles in let _ = (currentPeerId.get() |> take(1) |> deliverOnMainQueue).start(next: { peerId in - updateSignMessagesDisposable.set(context.engine.peers.toggleShouldChannelMessagesSignatures(peerId: peerId, enabled: value).start()) - }) - }, updateShowAuthorProfilesEnabled: { value in - let _ = (currentPeerId.get() - |> take(1) - |> deliverOnMainQueue).start(next: { peerId in - updateSignMessagesDisposable.set(context.engine.peers.toggleShouldChannelMessagesSignatures(peerId: peerId, enabled: value).start()) + updateSignMessagesDisposable.set(context.engine.peers.toggleShouldChannelMessagesSignatures(peerId: peerId, signaturesEnabled: signatures, profilesEnabled: profiles).start()) }) }) @@ -947,7 +936,7 @@ public func channelAdminsController(context: AccountContext, updatedPresentation var showAuthorProfilesEnabled = false if case let .channel(channel) = view.peer, case let .broadcast(info) = channel.info { signMessagesEnabled = info.flags.contains(.messagesShouldHaveSignatures) - showAuthorProfilesEnabled = info.flags.contains(.messagesShouldHaveSignatures) + showAuthorProfilesEnabled = info.flags.contains(.messagesShouldHaveProfiles) } var rightNavigationButton: ItemListNavigationButton? diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index 8f398218f2..0c6273e8d0 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -170,6 +170,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[460916654] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleInvites($0) } dict[-886388890] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleNoForwards($0) } dict[1599903217] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionTogglePreHistoryHidden($0) } + dict[1621597305] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleSignatureProfiles($0) } dict[648939889] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleSignatures($0) } dict[1401984889] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleSlowMode($0) } dict[-370660328] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionUpdatePinned($0) } diff --git a/submodules/TelegramApi/Sources/Api3.swift b/submodules/TelegramApi/Sources/Api3.swift index 3ec0b4d752..4ee341396a 100644 --- a/submodules/TelegramApi/Sources/Api3.swift +++ b/submodules/TelegramApi/Sources/Api3.swift @@ -409,6 +409,7 @@ public extension Api { case channelAdminLogEventActionToggleInvites(newValue: Api.Bool) case channelAdminLogEventActionToggleNoForwards(newValue: Api.Bool) case channelAdminLogEventActionTogglePreHistoryHidden(newValue: Api.Bool) + case channelAdminLogEventActionToggleSignatureProfiles(newValue: Api.Bool) case channelAdminLogEventActionToggleSignatures(newValue: Api.Bool) case channelAdminLogEventActionToggleSlowMode(prevValue: Int32, newValue: Int32) case channelAdminLogEventActionUpdatePinned(message: Api.Message) @@ -718,6 +719,12 @@ public extension Api { } newValue.serialize(buffer, true) break + case .channelAdminLogEventActionToggleSignatureProfiles(let newValue): + if boxed { + buffer.appendInt32(1621597305) + } + newValue.serialize(buffer, true) + break case .channelAdminLogEventActionToggleSignatures(let newValue): if boxed { buffer.appendInt32(648939889) @@ -832,6 +839,8 @@ public extension Api { return ("channelAdminLogEventActionToggleNoForwards", [("newValue", newValue as Any)]) case .channelAdminLogEventActionTogglePreHistoryHidden(let newValue): return ("channelAdminLogEventActionTogglePreHistoryHidden", [("newValue", newValue as Any)]) + case .channelAdminLogEventActionToggleSignatureProfiles(let newValue): + return ("channelAdminLogEventActionToggleSignatureProfiles", [("newValue", newValue as Any)]) case .channelAdminLogEventActionToggleSignatures(let newValue): return ("channelAdminLogEventActionToggleSignatures", [("newValue", newValue as Any)]) case .channelAdminLogEventActionToggleSlowMode(let prevValue, let newValue): @@ -1505,6 +1514,19 @@ public extension Api { return nil } } + public static func parse_channelAdminLogEventActionToggleSignatureProfiles(_ reader: BufferReader) -> ChannelAdminLogEventAction? { + var _1: Api.Bool? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.Bool + } + let _c1 = _1 != nil + if _c1 { + return Api.ChannelAdminLogEventAction.channelAdminLogEventActionToggleSignatureProfiles(newValue: _1!) + } + else { + return nil + } + } public static func parse_channelAdminLogEventActionToggleSignatures(_ reader: BufferReader) -> ChannelAdminLogEventAction? { var _1: Api.Bool? if let signature = reader.readInt32() { diff --git a/submodules/TelegramApi/Sources/Api36.swift b/submodules/TelegramApi/Sources/Api36.swift index f69c2350f3..3074843dc8 100644 --- a/submodules/TelegramApi/Sources/Api36.swift +++ b/submodules/TelegramApi/Sources/Api36.swift @@ -3556,12 +3556,12 @@ public extension Api.functions.channels { } } public extension Api.functions.channels { - static func toggleSignatures(channel: Api.InputChannel, enabled: Api.Bool) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + static func toggleSignatures(flags: Int32, channel: Api.InputChannel) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(527021574) + buffer.appendInt32(1099781276) + serializeInt32(flags, buffer: buffer, boxed: false) channel.serialize(buffer, true) - enabled.serialize(buffer, true) - return (FunctionDescription(name: "channels.toggleSignatures", parameters: [("channel", String(describing: channel)), ("enabled", String(describing: enabled))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in + return (FunctionDescription(name: "channels.toggleSignatures", parameters: [("flags", String(describing: flags)), ("channel", String(describing: channel))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in let reader = BufferReader(buffer) var result: Api.Updates? if let signature = reader.readInt32() { diff --git a/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift b/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift index 0a3b612cfe..657ef472d9 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/ApiGroupOrChannel.swift @@ -85,6 +85,9 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? { if (flags & Int32(1 << 11)) != 0 { infoFlags.insert(.messagesShouldHaveSignatures) } + if (flags2 & Int32(1 << 12)) != 0 { + infoFlags.insert(.messagesShouldHaveProfiles) + } if (flags & Int32(1 << 20)) != 0 { infoFlags.insert(.hasDiscussionGroup) } diff --git a/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift b/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift index 13c3f5f895..4a04ad0d1e 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift @@ -714,7 +714,7 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId, } } - let authorId: PeerId? + var authorId: PeerId? if let sendAsPeer = sendAsPeer { authorId = sendAsPeer.id } else if let peer = peer as? TelegramChannel { @@ -745,6 +745,9 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId, if info.flags.contains(.messagesShouldHaveSignatures) { attributes.append(AuthorSignatureMessageAttribute(signature: accountPeer.debugDisplayTitle)) } + if info.flags.contains(.messagesShouldHaveProfiles) { + authorId = account.peerId + } case .group: break } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramChannel.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramChannel.swift index 717c902f4e..7b863fd86f 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramChannel.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramChannel.swift @@ -43,6 +43,7 @@ public struct TelegramChannelBroadcastFlags: OptionSet { public static let messagesShouldHaveSignatures = TelegramChannelBroadcastFlags(rawValue: 1 << 0) public static let hasDiscussionGroup = TelegramChannelBroadcastFlags(rawValue: 1 << 1) + public static let messagesShouldHaveProfiles = TelegramChannelBroadcastFlags(rawValue: 1 << 2) } public struct TelegramChannelBroadcastInfo: Equatable { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift index d113a071bc..bc455b6209 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ChannelAdminEventLogs.swift @@ -50,6 +50,7 @@ public enum AdminLogEventAction { case changePhoto(prev: ([TelegramMediaImageRepresentation], [TelegramMediaImage.VideoRepresentation]), new: ([TelegramMediaImageRepresentation], [TelegramMediaImage.VideoRepresentation])) case toggleInvites(Bool) case toggleSignatures(Bool) + case toggleSignatureProfiles(Bool) case updatePinned(Message?) case editMessage(prev: Message, new: Message) case deleteMessage(Message) @@ -446,6 +447,8 @@ func channelAdminLogEvents(accountPeerId: PeerId, postbox: Postbox, network: Net action = .changeStatus(prev: PeerEmojiStatus(apiStatus: prevValue), new: PeerEmojiStatus(apiStatus: newValue)) case let .channelAdminLogEventActionChangeEmojiStickerSet(prevStickerset, newStickerset): action = .changeEmojiPack(prev: StickerPackReference(apiInputSet: prevStickerset), new: StickerPackReference(apiInputSet: newStickerset)) + case let .channelAdminLogEventActionToggleSignatureProfiles(newValue): + action = .toggleSignatureProfiles(boolFromApiValue(newValue)) } let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) if let action = action { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift index 948d724634..765304b395 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/TelegramEnginePeers.swift @@ -458,8 +458,8 @@ public extension TelegramEngine { } } - public func toggleShouldChannelMessagesSignatures(peerId: PeerId, enabled: Bool) -> Signal { - return _internal_toggleShouldChannelMessagesSignatures(account: self.account, peerId: peerId, enabled: enabled) + public func toggleShouldChannelMessagesSignatures(peerId: PeerId, signaturesEnabled: Bool, profilesEnabled: Bool) -> Signal { + return _internal_toggleShouldChannelMessagesSignatures(account: self.account, peerId: peerId, signaturesEnabled: signaturesEnabled, profilesEnabled: profilesEnabled) } public func toggleMessageCopyProtection(peerId: PeerId, enabled: Bool) -> Signal { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ToggleChannelSignatures.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ToggleChannelSignatures.swift index e6ed0ae26d..bec0218e31 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/ToggleChannelSignatures.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/ToggleChannelSignatures.swift @@ -5,10 +5,17 @@ import TelegramApi import MtProtoKit -func _internal_toggleShouldChannelMessagesSignatures(account: Account, peerId: PeerId, enabled: Bool) -> Signal { +func _internal_toggleShouldChannelMessagesSignatures(account: Account, peerId: PeerId, signaturesEnabled: Bool, profilesEnabled: Bool) -> Signal { return account.postbox.transaction { transaction -> Signal in if let peer = transaction.getPeer(peerId) as? TelegramChannel, let inputChannel = apiInputChannel(peer) { - return account.network.request(Api.functions.channels.toggleSignatures(channel: inputChannel, enabled: enabled ? .boolTrue : .boolFalse)) |> retryRequest |> map { updates -> Void in + var flags: Int32 = 0 + if signaturesEnabled { + flags |= 1 << 0 + } + if profilesEnabled { + flags |= 1 << 1 + } + return account.network.request(Api.functions.channels.toggleSignatures(flags: flags, channel: inputChannel)) |> retryRequest |> map { updates -> Void in account.stateManager.addUpdates(updates) } } else { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift index 0600467200..5ed325f2a3 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageBubbleItemNode/Sources/ChatMessageBubbleItemNode.swift @@ -1480,7 +1480,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI } var effectiveAuthor: Peer? - var overrideEffectiveAuthor = false + let overrideEffectiveAuthor = false var ignoreForward = false var displayAuthorInfo: Bool var ignoreNameHiding = false @@ -1551,7 +1551,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI } //TODO:release - if let channel = firstMessage.peers[firstMessage.id.peerId] as? TelegramChannel, case let .broadcast(info) = channel.info, info.flags.contains(.messagesShouldHaveSignatures) { + /*if let channel = firstMessage.peers[firstMessage.id.peerId] as? TelegramChannel, case let .broadcast(info) = channel.info, info.flags.contains(.messagesShouldHaveProfiles) { hasAvatar = true if let authorSignatureAttribute = firstMessage.authorSignatureAttribute { effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignatureAttribute.signature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignatureAttribute.signature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil) @@ -1573,7 +1573,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI displayAuthorInfo = false } } - } + }*/ if !peerId.isRepliesOrSavedMessages(accountPeerId: item.context.account.peerId) { if peerId.isGroupOrChannel && effectiveAuthor != nil { diff --git a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift index ae81587ac4..507bb11f17 100644 --- a/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift +++ b/submodules/TelegramUI/Components/Chat/ChatMessageItemImpl/Sources/ChatMessageItemImpl.swift @@ -344,13 +344,13 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible if !hasActionMedia { if !isBroadcastChannel { hasAvatar = true - } else if let channel = message.peers[message.id.peerId] as? TelegramChannel, case let .broadcast(info) = channel.info, info.flags.contains(.messagesShouldHaveSignatures) { + }/* else if let channel = message.peers[message.id.peerId] as? TelegramChannel, case let .broadcast(info) = channel.info, info.flags.contains(.messagesShouldHaveProfiles) { //TODO:release hasAvatar = true if let authorSignatureAttribute = message.authorSignatureAttribute { effectiveAuthor = TelegramUser(id: PeerId(namespace: Namespaces.Peer.Empty, id: PeerId.Id._internalFromInt64Value(Int64(authorSignatureAttribute.signature.persistentHashValue % 32))), accessHash: nil, firstName: authorSignatureAttribute.signature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [], emojiStatus: nil, usernames: [], storiesHidden: nil, nameColor: nil, backgroundEmojiId: nil, profileColor: nil, profileBackgroundEmojiId: nil, subscriberCount: nil) } - } + }*/ } if hasAvatar { diff --git a/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsHistoryTransition.swift b/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsHistoryTransition.swift index 4ae6888f65..f85b2ae55f 100644 --- a/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsHistoryTransition.swift +++ b/submodules/TelegramUI/Components/Chat/ChatRecentActionsController/Sources/ChatRecentActionsHistoryTransition.swift @@ -347,7 +347,7 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { let action = TelegramMediaActionType.customText(text: text, entities: entities, additionalAttributes: nil) let message = Message(stableId: self.entry.stableId, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: Int32(bitPattern: self.entry.stableId)), globallyUniqueId: self.entry.event.id, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: self.entry.event.date, flags: [.Incoming], tags: [], globalTags: [], localTags: [], customTags: [], forwardInfo: nil, author: author, text: "", attributes: [], media: [TelegramMediaAction(action: action)], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [], associatedMedia: [:], associatedThreadInfo: nil, associatedStories: [:]) return ChatMessageItemImpl(presentationData: self.presentationData, context: context, chatLocation: .peer(id: peer.id), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .channel, automaticDownloadPeerId: nil, automaticDownloadNetworkType: .cellular, isRecentActions: true, availableReactions: availableReactions, availableMessageEffects: availableMessageEffects, savedMessageTags: nil, defaultReaction: nil, isPremium: false, accountPeer: nil), controllerInteraction: controllerInteraction, content: .message(message: message, read: true, selection: .none, attributes: ChatMessageEntryAttributes(), location: nil)) - case let .toggleSignatures(value): + case .toggleSignatures(let value), .toggleSignatureProfiles(let value): var peers = SimpleDictionary() var author: Peer? if let peer = self.entry.peers[self.entry.event.peerId] { @@ -357,14 +357,28 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { var text: String = "" var entities: [MessageTextEntity] = [] if value { - appendAttributedText(text: self.presentationData.strings.Channel_AdminLog_MessageToggleSignaturesOn(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? ""), generateEntities: { index in + let pattern: (String) -> PresentationStrings.FormattedString + if case .toggleSignatureProfiles = self.entry.event.action { + pattern = self.presentationData.strings.Channel_AdminLog_MessageToggleProfileSignaturesOn + } else { + pattern = self.presentationData.strings.Channel_AdminLog_MessageToggleSignaturesOn + } + + appendAttributedText(text: pattern(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? ""), generateEntities: { index in if index == 0, let author = author { return [.TextMention(peerId: author.id)] } return [] }, to: &text, entities: &entities) } else { - appendAttributedText(text: self.presentationData.strings.Channel_AdminLog_MessageToggleSignaturesOff(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? ""), generateEntities: { index in + let pattern: (String) -> PresentationStrings.FormattedString + if case .toggleSignatureProfiles = self.entry.event.action { + pattern = self.presentationData.strings.Channel_AdminLog_MessageToggleProfileSignaturesOff + } else { + pattern = self.presentationData.strings.Channel_AdminLog_MessageToggleSignaturesOff + } + + appendAttributedText(text: pattern(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? ""), generateEntities: { index in if index == 0, let author = author { return [.TextMention(peerId: author.id)] } diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index b6a60d4137..c7cb6ffd85 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -559,7 +559,6 @@ private final class PeerInfoInteraction { let editingOpenInviteLinksSetup: () -> Void let editingOpenDiscussionGroupSetup: () -> Void let editingOpenStars: () -> Void - let editingToggleMessageSignatures: (Bool) -> Void let openParticipantsSection: (PeerInfoParticipantsSection) -> Void let openRecentActions: () -> Void let openStats: (ChannelStatsSection) -> Void @@ -627,7 +626,6 @@ private final class PeerInfoInteraction { editingOpenInviteLinksSetup: @escaping () -> Void, editingOpenDiscussionGroupSetup: @escaping () -> Void, editingOpenStars: @escaping () -> Void, - editingToggleMessageSignatures: @escaping (Bool) -> Void, openParticipantsSection: @escaping (PeerInfoParticipantsSection) -> Void, openRecentActions: @escaping () -> Void, openStats: @escaping (ChannelStatsSection) -> Void, @@ -694,7 +692,6 @@ private final class PeerInfoInteraction { self.editingOpenInviteLinksSetup = editingOpenInviteLinksSetup self.editingOpenDiscussionGroupSetup = editingOpenDiscussionGroupSetup self.editingOpenStars = editingOpenStars - self.editingToggleMessageSignatures = editingToggleMessageSignatures self.openParticipantsSection = openParticipantsSection self.openRecentActions = openRecentActions self.openStats = openStats @@ -2762,9 +2759,6 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro editingOpenStars: { [weak self] in self?.editingOpenStars() }, - editingToggleMessageSignatures: { [weak self] value in - self?.editingToggleMessageSignatures(value: value) - }, openParticipantsSection: { [weak self] section in self?.openParticipantsSection(section: section) }, @@ -8565,10 +8559,6 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro let _ = self.context.engine.peers.setChannelForumMode(id: self.peerId, isForum: isEnabled).startStandalone() } } - - private func editingToggleMessageSignatures(value: Bool) { - self.toggleShouldChannelMessagesSignaturesDisposable.set(self.context.engine.peers.toggleShouldChannelMessagesSignatures(peerId: self.peerId, enabled: value).startStrict()) - } private func openParticipantsSection(section: PeerInfoParticipantsSection) { guard let data = self.data, let peer = data.peer else {