Update API [skip ci]

This commit is contained in:
Isaac 2024-08-08 14:15:32 +04:00
parent 2cc5c02003
commit 289273dcd9
15 changed files with 92 additions and 56 deletions

View File

@ -12672,3 +12672,6 @@ Sorry for the inconvenience.";
"Stars.Intro.GiftStars" = "Gift Stars to Friends"; "Stars.Intro.GiftStars" = "Gift Stars to Friends";
"MediaPicker.CreateSticker" = "Create a sticker from a photo"; "MediaPicker.CreateSticker" = "Create a sticker from a photo";
"Channel.AdminLog.MessageToggleProfileSignaturesOn" = "%@ enabled admin profiles";
"Channel.AdminLog.MessageToggleProfileSignaturesOff" = "%@ disabled admin profiles";

View File

@ -24,10 +24,9 @@ private final class ChannelAdminsControllerArguments {
let addAdmin: () -> Void let addAdmin: () -> Void
let openAdmin: (ChannelParticipant) -> Void let openAdmin: (ChannelParticipant) -> Void
let updateAntiSpamEnabled: (Bool) -> Void let updateAntiSpamEnabled: (Bool) -> Void
let updateSignMessagesEnabled: (Bool) -> Void let updateSignaturesAndProfilesEnabled: (Bool, Bool) -> Void
let updateShowAuthorProfilesEnabled: (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.context = context
self.openRecentActions = openRecentActions self.openRecentActions = openRecentActions
self.setPeerIdWithRevealedOptions = setPeerIdWithRevealedOptions self.setPeerIdWithRevealedOptions = setPeerIdWithRevealedOptions
@ -35,8 +34,7 @@ private final class ChannelAdminsControllerArguments {
self.addAdmin = addAdmin self.addAdmin = addAdmin
self.openAdmin = openAdmin self.openAdmin = openAdmin
self.updateAntiSpamEnabled = updateAntiSpamEnabled self.updateAntiSpamEnabled = updateAntiSpamEnabled
self.updateSignMessagesEnabled = updateSignMessagesEnabled self.updateSignaturesAndProfilesEnabled = updateSignaturesAndProfilesEnabled
self.updateShowAuthorProfilesEnabled = updateShowAuthorProfilesEnabled
} }
} }
@ -61,8 +59,8 @@ private enum ChannelAdminsEntry: ItemListNodeEntry {
case addAdmin(PresentationTheme, String, Bool) case addAdmin(PresentationTheme, String, Bool)
case adminsInfo(PresentationTheme, String) case adminsInfo(PresentationTheme, String)
case signMessages(PresentationTheme, String, Bool) case signMessages(PresentationTheme, String, Bool, Bool)
case showAuthorProfiles(PresentationTheme, String, Bool) case showAuthorProfiles(PresentationTheme, String, Bool, Bool)
case signMessagesInfo(PresentationTheme, String) case signMessagesInfo(PresentationTheme, String)
var section: ItemListSectionId { var section: ItemListSectionId {
@ -175,14 +173,14 @@ private enum ChannelAdminsEntry: ItemListNodeEntry {
} else { } else {
return false return false
} }
case let .signMessages(lhsTheme, lhsText, lhsValue): case let .signMessages(lhsTheme, lhsText, lhsValue, lhsOtherValue):
if case let .signMessages(rhsTheme, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue { if case let .signMessages(rhsTheme, rhsText, rhsValue, rhsOtherValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue, lhsOtherValue == rhsOtherValue {
return true return true
} else { } else {
return false return false
} }
case let .showAuthorProfiles(lhsTheme, lhsText, lhsValue): case let .showAuthorProfiles(lhsTheme, lhsText, lhsValue, lhsOtherValue):
if case let .showAuthorProfiles(rhsTheme, rhsText, rhsValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue { if case let .showAuthorProfiles(rhsTheme, rhsText, rhsValue, rhsOtherValue) = rhs, lhsTheme === rhsTheme, lhsText == rhsText, lhsValue == rhsValue, lhsOtherValue == rhsOtherValue {
return true return true
} else { } else {
return false return false
@ -315,13 +313,13 @@ private enum ChannelAdminsEntry: ItemListNodeEntry {
}) })
case let .adminsInfo(_, text): case let .adminsInfo(_, text):
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section) 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 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 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): case let .signMessagesInfo(_, text):
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section) return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
@ -497,9 +495,9 @@ private func channelAdminsControllerEntries(presentationData: PresentationData,
} }
if !isGroup && peer.hasPermission(.sendSomething) { 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 //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.")) 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() let updateSignMessagesDisposable = MetaDisposable()
actionsDisposable.add(updateSignMessagesDisposable) actionsDisposable.add(updateSignMessagesDisposable)
let updateShowAuthorProfilesDisposable = MetaDisposable()
actionsDisposable.add(updateShowAuthorProfilesDisposable)
let adminsPromise = Promise<[RenderedChannelParticipant]?>(nil) let adminsPromise = Promise<[RenderedChannelParticipant]?>(nil)
let antiSpamConfiguration = AntiSpamBotConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 }) let antiSpamConfiguration = AntiSpamBotConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
@ -811,17 +806,11 @@ public func channelAdminsController(context: AccountContext, updatedPresentation
|> deliverOnMainQueue).start(next: { peerId in |> deliverOnMainQueue).start(next: { peerId in
updateAntiSpamDisposable.set(context.engine.peers.toggleAntiSpamProtection(peerId: peerId, enabled: value).start()) updateAntiSpamDisposable.set(context.engine.peers.toggleAntiSpamProtection(peerId: peerId, enabled: value).start())
}) })
}, updateSignMessagesEnabled: { value in }, updateSignaturesAndProfilesEnabled: { signatures, profiles in
let _ = (currentPeerId.get() let _ = (currentPeerId.get()
|> take(1) |> take(1)
|> deliverOnMainQueue).start(next: { peerId in |> 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())
})
}, updateShowAuthorProfilesEnabled: { value in
let _ = (currentPeerId.get()
|> take(1)
|> deliverOnMainQueue).start(next: { peerId in
updateSignMessagesDisposable.set(context.engine.peers.toggleShouldChannelMessagesSignatures(peerId: peerId, enabled: value).start())
}) })
}) })
@ -947,7 +936,7 @@ public func channelAdminsController(context: AccountContext, updatedPresentation
var showAuthorProfilesEnabled = false var showAuthorProfilesEnabled = false
if case let .channel(channel) = view.peer, case let .broadcast(info) = channel.info { if case let .channel(channel) = view.peer, case let .broadcast(info) = channel.info {
signMessagesEnabled = info.flags.contains(.messagesShouldHaveSignatures) signMessagesEnabled = info.flags.contains(.messagesShouldHaveSignatures)
showAuthorProfilesEnabled = info.flags.contains(.messagesShouldHaveSignatures) showAuthorProfilesEnabled = info.flags.contains(.messagesShouldHaveProfiles)
} }
var rightNavigationButton: ItemListNavigationButton? var rightNavigationButton: ItemListNavigationButton?

View File

@ -170,6 +170,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[460916654] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleInvites($0) } dict[460916654] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleInvites($0) }
dict[-886388890] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleNoForwards($0) } dict[-886388890] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleNoForwards($0) }
dict[1599903217] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionTogglePreHistoryHidden($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[648939889] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleSignatures($0) }
dict[1401984889] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleSlowMode($0) } dict[1401984889] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionToggleSlowMode($0) }
dict[-370660328] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionUpdatePinned($0) } dict[-370660328] = { return Api.ChannelAdminLogEventAction.parse_channelAdminLogEventActionUpdatePinned($0) }

View File

@ -409,6 +409,7 @@ public extension Api {
case channelAdminLogEventActionToggleInvites(newValue: Api.Bool) case channelAdminLogEventActionToggleInvites(newValue: Api.Bool)
case channelAdminLogEventActionToggleNoForwards(newValue: Api.Bool) case channelAdminLogEventActionToggleNoForwards(newValue: Api.Bool)
case channelAdminLogEventActionTogglePreHistoryHidden(newValue: Api.Bool) case channelAdminLogEventActionTogglePreHistoryHidden(newValue: Api.Bool)
case channelAdminLogEventActionToggleSignatureProfiles(newValue: Api.Bool)
case channelAdminLogEventActionToggleSignatures(newValue: Api.Bool) case channelAdminLogEventActionToggleSignatures(newValue: Api.Bool)
case channelAdminLogEventActionToggleSlowMode(prevValue: Int32, newValue: Int32) case channelAdminLogEventActionToggleSlowMode(prevValue: Int32, newValue: Int32)
case channelAdminLogEventActionUpdatePinned(message: Api.Message) case channelAdminLogEventActionUpdatePinned(message: Api.Message)
@ -718,6 +719,12 @@ public extension Api {
} }
newValue.serialize(buffer, true) newValue.serialize(buffer, true)
break break
case .channelAdminLogEventActionToggleSignatureProfiles(let newValue):
if boxed {
buffer.appendInt32(1621597305)
}
newValue.serialize(buffer, true)
break
case .channelAdminLogEventActionToggleSignatures(let newValue): case .channelAdminLogEventActionToggleSignatures(let newValue):
if boxed { if boxed {
buffer.appendInt32(648939889) buffer.appendInt32(648939889)
@ -832,6 +839,8 @@ public extension Api {
return ("channelAdminLogEventActionToggleNoForwards", [("newValue", newValue as Any)]) return ("channelAdminLogEventActionToggleNoForwards", [("newValue", newValue as Any)])
case .channelAdminLogEventActionTogglePreHistoryHidden(let newValue): case .channelAdminLogEventActionTogglePreHistoryHidden(let newValue):
return ("channelAdminLogEventActionTogglePreHistoryHidden", [("newValue", newValue as Any)]) return ("channelAdminLogEventActionTogglePreHistoryHidden", [("newValue", newValue as Any)])
case .channelAdminLogEventActionToggleSignatureProfiles(let newValue):
return ("channelAdminLogEventActionToggleSignatureProfiles", [("newValue", newValue as Any)])
case .channelAdminLogEventActionToggleSignatures(let newValue): case .channelAdminLogEventActionToggleSignatures(let newValue):
return ("channelAdminLogEventActionToggleSignatures", [("newValue", newValue as Any)]) return ("channelAdminLogEventActionToggleSignatures", [("newValue", newValue as Any)])
case .channelAdminLogEventActionToggleSlowMode(let prevValue, let newValue): case .channelAdminLogEventActionToggleSlowMode(let prevValue, let newValue):
@ -1505,6 +1514,19 @@ public extension Api {
return nil 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? { public static func parse_channelAdminLogEventActionToggleSignatures(_ reader: BufferReader) -> ChannelAdminLogEventAction? {
var _1: Api.Bool? var _1: Api.Bool?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {

View File

@ -3556,12 +3556,12 @@ public extension Api.functions.channels {
} }
} }
public extension Api.functions.channels { public extension Api.functions.channels {
static func toggleSignatures(channel: Api.InputChannel, enabled: Api.Bool) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) { static func toggleSignatures(flags: Int32, channel: Api.InputChannel) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer() let buffer = Buffer()
buffer.appendInt32(527021574) buffer.appendInt32(1099781276)
serializeInt32(flags, buffer: buffer, boxed: false)
channel.serialize(buffer, true) channel.serialize(buffer, true)
enabled.serialize(buffer, true) return (FunctionDescription(name: "channels.toggleSignatures", parameters: [("flags", String(describing: flags)), ("channel", String(describing: channel))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
return (FunctionDescription(name: "channels.toggleSignatures", parameters: [("channel", String(describing: channel)), ("enabled", String(describing: enabled))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
let reader = BufferReader(buffer) let reader = BufferReader(buffer)
var result: Api.Updates? var result: Api.Updates?
if let signature = reader.readInt32() { if let signature = reader.readInt32() {

View File

@ -85,6 +85,9 @@ func parseTelegramGroupOrChannel(chat: Api.Chat) -> Peer? {
if (flags & Int32(1 << 11)) != 0 { if (flags & Int32(1 << 11)) != 0 {
infoFlags.insert(.messagesShouldHaveSignatures) infoFlags.insert(.messagesShouldHaveSignatures)
} }
if (flags2 & Int32(1 << 12)) != 0 {
infoFlags.insert(.messagesShouldHaveProfiles)
}
if (flags & Int32(1 << 20)) != 0 { if (flags & Int32(1 << 20)) != 0 {
infoFlags.insert(.hasDiscussionGroup) infoFlags.insert(.hasDiscussionGroup)
} }

View File

@ -714,7 +714,7 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
} }
} }
let authorId: PeerId? var authorId: PeerId?
if let sendAsPeer = sendAsPeer { if let sendAsPeer = sendAsPeer {
authorId = sendAsPeer.id authorId = sendAsPeer.id
} else if let peer = peer as? TelegramChannel { } else if let peer = peer as? TelegramChannel {
@ -745,6 +745,9 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
if info.flags.contains(.messagesShouldHaveSignatures) { if info.flags.contains(.messagesShouldHaveSignatures) {
attributes.append(AuthorSignatureMessageAttribute(signature: accountPeer.debugDisplayTitle)) attributes.append(AuthorSignatureMessageAttribute(signature: accountPeer.debugDisplayTitle))
} }
if info.flags.contains(.messagesShouldHaveProfiles) {
authorId = account.peerId
}
case .group: case .group:
break break
} }

View File

@ -43,6 +43,7 @@ public struct TelegramChannelBroadcastFlags: OptionSet {
public static let messagesShouldHaveSignatures = TelegramChannelBroadcastFlags(rawValue: 1 << 0) public static let messagesShouldHaveSignatures = TelegramChannelBroadcastFlags(rawValue: 1 << 0)
public static let hasDiscussionGroup = TelegramChannelBroadcastFlags(rawValue: 1 << 1) public static let hasDiscussionGroup = TelegramChannelBroadcastFlags(rawValue: 1 << 1)
public static let messagesShouldHaveProfiles = TelegramChannelBroadcastFlags(rawValue: 1 << 2)
} }
public struct TelegramChannelBroadcastInfo: Equatable { public struct TelegramChannelBroadcastInfo: Equatable {

View File

@ -50,6 +50,7 @@ public enum AdminLogEventAction {
case changePhoto(prev: ([TelegramMediaImageRepresentation], [TelegramMediaImage.VideoRepresentation]), new: ([TelegramMediaImageRepresentation], [TelegramMediaImage.VideoRepresentation])) case changePhoto(prev: ([TelegramMediaImageRepresentation], [TelegramMediaImage.VideoRepresentation]), new: ([TelegramMediaImageRepresentation], [TelegramMediaImage.VideoRepresentation]))
case toggleInvites(Bool) case toggleInvites(Bool)
case toggleSignatures(Bool) case toggleSignatures(Bool)
case toggleSignatureProfiles(Bool)
case updatePinned(Message?) case updatePinned(Message?)
case editMessage(prev: Message, new: Message) case editMessage(prev: Message, new: Message)
case deleteMessage(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)) action = .changeStatus(prev: PeerEmojiStatus(apiStatus: prevValue), new: PeerEmojiStatus(apiStatus: newValue))
case let .channelAdminLogEventActionChangeEmojiStickerSet(prevStickerset, newStickerset): case let .channelAdminLogEventActionChangeEmojiStickerSet(prevStickerset, newStickerset):
action = .changeEmojiPack(prev: StickerPackReference(apiInputSet: prevStickerset), new: StickerPackReference(apiInputSet: 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)) let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
if let action = action { if let action = action {

View File

@ -458,8 +458,8 @@ public extension TelegramEngine {
} }
} }
public func toggleShouldChannelMessagesSignatures(peerId: PeerId, enabled: Bool) -> Signal<Void, NoError> { public func toggleShouldChannelMessagesSignatures(peerId: PeerId, signaturesEnabled: Bool, profilesEnabled: Bool) -> Signal<Void, NoError> {
return _internal_toggleShouldChannelMessagesSignatures(account: self.account, peerId: peerId, enabled: enabled) return _internal_toggleShouldChannelMessagesSignatures(account: self.account, peerId: peerId, signaturesEnabled: signaturesEnabled, profilesEnabled: profilesEnabled)
} }
public func toggleMessageCopyProtection(peerId: PeerId, enabled: Bool) -> Signal<Void, NoError> { public func toggleMessageCopyProtection(peerId: PeerId, enabled: Bool) -> Signal<Void, NoError> {

View File

@ -5,10 +5,17 @@ import TelegramApi
import MtProtoKit import MtProtoKit
func _internal_toggleShouldChannelMessagesSignatures(account: Account, peerId: PeerId, enabled: Bool) -> Signal<Void, NoError> { func _internal_toggleShouldChannelMessagesSignatures(account: Account, peerId: PeerId, signaturesEnabled: Bool, profilesEnabled: Bool) -> Signal<Void, NoError> {
return account.postbox.transaction { transaction -> Signal<Void, NoError> in return account.postbox.transaction { transaction -> Signal<Void, NoError> in
if let peer = transaction.getPeer(peerId) as? TelegramChannel, let inputChannel = apiInputChannel(peer) { 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) account.stateManager.addUpdates(updates)
} }
} else { } else {

View File

@ -1480,7 +1480,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
} }
var effectiveAuthor: Peer? var effectiveAuthor: Peer?
var overrideEffectiveAuthor = false let overrideEffectiveAuthor = false
var ignoreForward = false var ignoreForward = false
var displayAuthorInfo: Bool var displayAuthorInfo: Bool
var ignoreNameHiding = false var ignoreNameHiding = false
@ -1551,7 +1551,7 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
} }
//TODO:release //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 hasAvatar = true
if let authorSignatureAttribute = firstMessage.authorSignatureAttribute { 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) 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 displayAuthorInfo = false
} }
} }
} }*/
if !peerId.isRepliesOrSavedMessages(accountPeerId: item.context.account.peerId) { if !peerId.isRepliesOrSavedMessages(accountPeerId: item.context.account.peerId) {
if peerId.isGroupOrChannel && effectiveAuthor != nil { if peerId.isGroupOrChannel && effectiveAuthor != nil {

View File

@ -344,13 +344,13 @@ public final class ChatMessageItemImpl: ChatMessageItem, CustomStringConvertible
if !hasActionMedia { if !hasActionMedia {
if !isBroadcastChannel { if !isBroadcastChannel {
hasAvatar = true 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 //TODO:release
hasAvatar = true hasAvatar = true
if let authorSignatureAttribute = message.authorSignatureAttribute { 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) 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 { if hasAvatar {

View File

@ -347,7 +347,7 @@ struct ChatRecentActionsEntry: Comparable, Identifiable {
let action = TelegramMediaActionType.customText(text: text, entities: entities, additionalAttributes: nil) 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: [:]) 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)) 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<PeerId, Peer>() var peers = SimpleDictionary<PeerId, Peer>()
var author: Peer? var author: Peer?
if let peer = self.entry.peers[self.entry.event.peerId] { if let peer = self.entry.peers[self.entry.event.peerId] {
@ -357,14 +357,28 @@ struct ChatRecentActionsEntry: Comparable, Identifiable {
var text: String = "" var text: String = ""
var entities: [MessageTextEntity] = [] var entities: [MessageTextEntity] = []
if value { 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 { if index == 0, let author = author {
return [.TextMention(peerId: author.id)] return [.TextMention(peerId: author.id)]
} }
return [] return []
}, to: &text, entities: &entities) }, to: &text, entities: &entities)
} else { } 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 { if index == 0, let author = author {
return [.TextMention(peerId: author.id)] return [.TextMention(peerId: author.id)]
} }

View File

@ -559,7 +559,6 @@ private final class PeerInfoInteraction {
let editingOpenInviteLinksSetup: () -> Void let editingOpenInviteLinksSetup: () -> Void
let editingOpenDiscussionGroupSetup: () -> Void let editingOpenDiscussionGroupSetup: () -> Void
let editingOpenStars: () -> Void let editingOpenStars: () -> Void
let editingToggleMessageSignatures: (Bool) -> Void
let openParticipantsSection: (PeerInfoParticipantsSection) -> Void let openParticipantsSection: (PeerInfoParticipantsSection) -> Void
let openRecentActions: () -> Void let openRecentActions: () -> Void
let openStats: (ChannelStatsSection) -> Void let openStats: (ChannelStatsSection) -> Void
@ -627,7 +626,6 @@ private final class PeerInfoInteraction {
editingOpenInviteLinksSetup: @escaping () -> Void, editingOpenInviteLinksSetup: @escaping () -> Void,
editingOpenDiscussionGroupSetup: @escaping () -> Void, editingOpenDiscussionGroupSetup: @escaping () -> Void,
editingOpenStars: @escaping () -> Void, editingOpenStars: @escaping () -> Void,
editingToggleMessageSignatures: @escaping (Bool) -> Void,
openParticipantsSection: @escaping (PeerInfoParticipantsSection) -> Void, openParticipantsSection: @escaping (PeerInfoParticipantsSection) -> Void,
openRecentActions: @escaping () -> Void, openRecentActions: @escaping () -> Void,
openStats: @escaping (ChannelStatsSection) -> Void, openStats: @escaping (ChannelStatsSection) -> Void,
@ -694,7 +692,6 @@ private final class PeerInfoInteraction {
self.editingOpenInviteLinksSetup = editingOpenInviteLinksSetup self.editingOpenInviteLinksSetup = editingOpenInviteLinksSetup
self.editingOpenDiscussionGroupSetup = editingOpenDiscussionGroupSetup self.editingOpenDiscussionGroupSetup = editingOpenDiscussionGroupSetup
self.editingOpenStars = editingOpenStars self.editingOpenStars = editingOpenStars
self.editingToggleMessageSignatures = editingToggleMessageSignatures
self.openParticipantsSection = openParticipantsSection self.openParticipantsSection = openParticipantsSection
self.openRecentActions = openRecentActions self.openRecentActions = openRecentActions
self.openStats = openStats self.openStats = openStats
@ -2762,9 +2759,6 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
editingOpenStars: { [weak self] in editingOpenStars: { [weak self] in
self?.editingOpenStars() self?.editingOpenStars()
}, },
editingToggleMessageSignatures: { [weak self] value in
self?.editingToggleMessageSignatures(value: value)
},
openParticipantsSection: { [weak self] section in openParticipantsSection: { [weak self] section in
self?.openParticipantsSection(section: section) self?.openParticipantsSection(section: section)
}, },
@ -8566,10 +8560,6 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
} }
} }
private func editingToggleMessageSignatures(value: Bool) {
self.toggleShouldChannelMessagesSignaturesDisposable.set(self.context.engine.peers.toggleShouldChannelMessagesSignatures(peerId: self.peerId, enabled: value).startStrict())
}
private func openParticipantsSection(section: PeerInfoParticipantsSection) { private func openParticipantsSection(section: PeerInfoParticipantsSection) {
guard let data = self.data, let peer = data.peer else { guard let data = self.data, let peer = data.peer else {
return return