Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin 2024-08-08 15:35:02 +02:00
commit aa3296cf95
18 changed files with 163 additions and 84 deletions

View File

@ -12673,6 +12673,9 @@ Sorry for the inconvenience.";
"MediaPicker.CreateSticker" = "Create a sticker from a photo";
"Channel.AdminLog.MessageToggleProfileSignaturesOn" = "%@ enabled admin profiles";
"Channel.AdminLog.MessageToggleProfileSignaturesOff" = "%@ disabled admin profiles";
"Stickers.CreateSticker" = "Create\nSticker";
"InviteLink.CreateNewInfo" = "You can create additional invite links that are limited by time, number of users, or require a paid subscription.";

View File

@ -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?

View File

@ -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) }

View File

@ -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() {

View File

@ -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<Api.Updates>) {
static func toggleSignatures(flags: Int32, channel: Api.InputChannel) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
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() {

View File

@ -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)
}

View File

@ -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
}

View File

@ -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 {

View File

@ -986,6 +986,31 @@ private final class StarsSubscriptionsContextImpl {
self.updateState(updatedState)
self.updateDisposable.set(_internal_updateStarsSubscription(account: self.account, peerId: self.account.peerId, subscriptionId: id, cancel: cancel).startStrict())
}
private var previousLoadTimestamp: Double?
func load(force: Bool) {
assert(Queue.mainQueue().isCurrent())
let currentTimestamp = CFAbsoluteTimeGetCurrent()
if let previousLoadTimestamp = self.previousLoadTimestamp, currentTimestamp - previousLoadTimestamp < 60 && !force {
return
}
self.previousLoadTimestamp = currentTimestamp
self.disposable.set((_internal_requestStarsSubscriptions(account: self.account, peerId: self.account.peerId, offset: "", missingBalance: false)
|> deliverOnMainQueue).start(next: { [weak self] status in
guard let self else {
return
}
self.nextOffset = status.nextSubscriptionsOffset
var updatedState = self._state
updatedState.subscriptions = status.subscriptions
updatedState.isLoading = false
updatedState.canLoadMore = self.nextOffset != nil
self.updateState(updatedState)
}))
}
}
public final class StarsSubscriptionsContext {
@ -1032,6 +1057,12 @@ public final class StarsSubscriptionsContext {
$0.updateSubscription(id: id, cancel: cancel)
}
}
public func load(force: Bool) {
self.impl.with {
$0.load(force: force)
}
}
}

View File

@ -93,5 +93,9 @@ public extension TelegramEngine {
public func sendStarsPaymentForm(formId: Int64, source: BotPaymentInvoiceSource) -> Signal<SendBotPaymentResult, SendBotPaymentFormError> {
return _internal_sendStarsPaymentForm(account: self.account, formId: formId, source: source)
}
public func fulfillStarsSubscription(peerId: EnginePeer.Id, subscriptionId: String) -> Signal<Never, FulfillStarsSubsciptionError> {
return _internal_fulfillStarsSubscription(account: self.account, peerId: peerId, subscriptionId: subscriptionId)
}
}
}

View File

@ -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 {

View File

@ -17,29 +17,35 @@ func _internal_joinChannel(account: Account, peerId: PeerId, hash: String?) -> S
|> take(1)
|> castError(JoinChannelError.self)
|> mapToSignal { peer -> Signal<RenderedChannelParticipant?, JoinChannelError> in
if let inputChannel = apiInputChannel(peer) {
let request: Signal<Api.Updates, MTRpcError>
if let hash = hash {
request = account.network.request(Api.functions.messages.importChatInvite(hash: hash))
} else {
request = account.network.request(Api.functions.channels.joinChannel(channel: inputChannel))
let request: Signal<Api.Updates, MTRpcError>
if let hash = hash {
request = account.network.request(Api.functions.messages.importChatInvite(hash: hash))
} else if let inputChannel = apiInputChannel(peer) {
request = account.network.request(Api.functions.channels.joinChannel(channel: inputChannel))
} else {
request = .fail(.init())
}
return request
|> mapError { error -> JoinChannelError in
switch error.errorDescription {
case "CHANNELS_TOO_MUCH":
return .tooMuchJoined
case "USERS_TOO_MUCH":
return .tooMuchUsers
case "INVITE_REQUEST_SENT":
return .inviteRequestSent
default:
return .generic
}
return request
|> mapError { error -> JoinChannelError in
switch error.errorDescription {
case "CHANNELS_TOO_MUCH":
return .tooMuchJoined
case "USERS_TOO_MUCH":
return .tooMuchUsers
case "INVITE_REQUEST_SENT":
return .inviteRequestSent
default:
return .generic
}
}
|> mapToSignal { updates -> Signal<RenderedChannelParticipant?, JoinChannelError> in
account.stateManager.addUpdates(updates)
}
|> mapToSignal { updates -> Signal<RenderedChannelParticipant?, JoinChannelError> in
account.stateManager.addUpdates(updates)
let channels = updates.chats.compactMap { parseTelegramGroupOrChannel(chat: $0) }.compactMap(apiInputChannel)
if let inputChannel = channels.first {
return account.network.request(Api.functions.channels.getParticipant(channel: inputChannel, participant: .inputPeerSelf))
|> map(Optional.init)
|> `catch` { _ -> Signal<Api.channels.ChannelParticipant?, JoinChannelError> in
@ -76,14 +82,16 @@ func _internal_joinChannel(account: Account, peerId: PeerId, hash: String?) -> S
}
|> castError(JoinChannelError.self)
}
} else {
return .fail(.generic)
}
|> afterCompleted {
if hash == nil {
let _ = _internal_requestRecommendedChannels(account: account, peerId: peerId, forceUpdate: true).startStandalone()
}
}
|> afterCompleted {
if hash == nil {
let _ = _internal_requestRecommendedChannels(account: account, peerId: peerId, forceUpdate: true).startStandalone()
}
} else {
return .fail(.generic)
}
}
}

View File

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

View File

@ -5,10 +5,17 @@ import TelegramApi
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
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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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<PeerId, Peer>()
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)]
}

View File

@ -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 {