From 54de3e7b9f548a95878ea365697bee5808202e83 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 6 Oct 2021 01:31:16 +0400 Subject: [PATCH] Update API --- .../Telegram-iOS/en.lproj/Localizable.strings | 3 ++ submodules/TelegramApi/Sources/Api0.swift | 3 +- submodules/TelegramApi/Sources/Api2.swift | 36 +++++++++++++------ .../ApiUtils/StoreMessage_Telegram.swift | 2 +- .../ApiUtils/TelegramMediaAction.swift | 2 ++ .../SyncCore_TelegramMediaAction.swift | 5 +++ .../Peers/InvitationLinks.swift | 7 ++-- .../Sources/ServiceMessageStrings.swift | 2 ++ 8 files changed, 46 insertions(+), 14 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 188bf740b0..f87ee06cf0 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -6919,3 +6919,6 @@ Ads should no longer be synonymous with abuse of user privacy. Let us redefine h "MemberRequests.RequestToJoinSent" = "Request to join Sent"; "MemberRequests.RequestToJoinSentDescriptionGroup" = "You will be added to the group once it admins approve your request."; "MemberRequests.RequestToJoinSentDescriptionChannel" = "You will be added to the channel once it admins approve your request."; + +"Notification.JoinedGroupByRequest" = "Your request to join the group was approved"; +"Notification.JoinedChannelByRequest" = "Your request to join the channel was approved"; diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index 9a7d02c050..204c9ed10c 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -578,7 +578,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1032140601] = { return Api.BotCommand.parse_botCommand($0) } dict[1474462241] = { return Api.account.ContentSettings.parse_contentSettings($0) } dict[-193506890] = { return Api.phone.GroupParticipants.parse_groupParticipants($0) } - dict[-1574303204] = { return Api.ChatInviteImporter.parse_chatInviteImporter($0) } + dict[-1940201511] = { return Api.ChatInviteImporter.parse_chatInviteImporter($0) } dict[-2066640507] = { return Api.messages.AffectedMessages.parse_affectedMessages($0) } dict[-402498398] = { return Api.messages.SavedGifs.parse_savedGifsNotModified($0) } dict[-2069878259] = { return Api.messages.SavedGifs.parse_savedGifs($0) } @@ -836,6 +836,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-1781355374] = { return Api.MessageAction.parse_messageActionChannelCreate($0) } dict[-519864430] = { return Api.MessageAction.parse_messageActionChatMigrateTo($0) } dict[-365344535] = { return Api.MessageAction.parse_messageActionChannelMigrateFrom($0) } + dict[-339958837] = { return Api.MessageAction.parse_messageActionChatJoinedByRequest($0) } dict[-1799538451] = { return Api.MessageAction.parse_messageActionPinMessage($0) } dict[-1615153660] = { return Api.MessageAction.parse_messageActionHistoryClear($0) } dict[-1834538890] = { return Api.MessageAction.parse_messageActionGameScore($0) } diff --git a/submodules/TelegramApi/Sources/Api2.swift b/submodules/TelegramApi/Sources/Api2.swift index 6e58fb3736..0fa2302e8e 100644 --- a/submodules/TelegramApi/Sources/Api2.swift +++ b/submodules/TelegramApi/Sources/Api2.swift @@ -14824,17 +14824,18 @@ public extension Api { } public enum ChatInviteImporter: TypeConstructorDescription { - case chatInviteImporter(flags: Int32, userId: Int64, date: Int32, approvedBy: Int64?) + case chatInviteImporter(flags: Int32, userId: Int64, date: Int32, about: String?, approvedBy: Int64?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { - case .chatInviteImporter(let flags, let userId, let date, let approvedBy): + case .chatInviteImporter(let flags, let userId, let date, let about, let approvedBy): if boxed { - buffer.appendInt32(-1574303204) + buffer.appendInt32(-1940201511) } serializeInt32(flags, buffer: buffer, boxed: false) serializeInt64(userId, buffer: buffer, boxed: false) serializeInt32(date, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 2) != 0 {serializeString(about!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 1) != 0 {serializeInt64(approvedBy!, buffer: buffer, boxed: false)} break } @@ -14842,8 +14843,8 @@ public extension Api { public func descriptionFields() -> (String, [(String, Any)]) { switch self { - case .chatInviteImporter(let flags, let userId, let date, let approvedBy): - return ("chatInviteImporter", [("flags", flags), ("userId", userId), ("date", date), ("approvedBy", approvedBy)]) + case .chatInviteImporter(let flags, let userId, let date, let about, let approvedBy): + return ("chatInviteImporter", [("flags", flags), ("userId", userId), ("date", date), ("about", about), ("approvedBy", approvedBy)]) } } @@ -14854,14 +14855,17 @@ public extension Api { _2 = reader.readInt64() var _3: Int32? _3 = reader.readInt32() - var _4: Int64? - if Int(_1!) & Int(1 << 1) != 0 {_4 = reader.readInt64() } + var _4: String? + if Int(_1!) & Int(1 << 2) != 0 {_4 = parseString(reader) } + var _5: Int64? + if Int(_1!) & Int(1 << 1) != 0 {_5 = reader.readInt64() } let _c1 = _1 != nil let _c2 = _2 != nil let _c3 = _3 != nil - let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil - if _c1 && _c2 && _c3 && _c4 { - return Api.ChatInviteImporter.chatInviteImporter(flags: _1!, userId: _2!, date: _3!, approvedBy: _4) + let _c4 = (Int(_1!) & Int(1 << 2) == 0) || _4 != nil + let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.ChatInviteImporter.chatInviteImporter(flags: _1!, userId: _2!, date: _3!, about: _4, approvedBy: _5) } else { return nil @@ -21033,6 +21037,7 @@ public extension Api { case messageActionChannelCreate(title: String) case messageActionChatMigrateTo(channelId: Int64) case messageActionChannelMigrateFrom(title: String, chatId: Int64) + case messageActionChatJoinedByRequest case messageActionPinMessage case messageActionHistoryClear case messageActionGameScore(gameId: Int64, score: Int32) @@ -21129,6 +21134,12 @@ public extension Api { } serializeString(title, buffer: buffer, boxed: false) serializeInt64(chatId, buffer: buffer, boxed: false) + break + case .messageActionChatJoinedByRequest: + if boxed { + buffer.appendInt32(-339958837) + } + break case .messageActionPinMessage: if boxed { @@ -21295,6 +21306,8 @@ public extension Api { return ("messageActionChatMigrateTo", [("channelId", channelId)]) case .messageActionChannelMigrateFrom(let title, let chatId): return ("messageActionChannelMigrateFrom", [("title", title), ("chatId", chatId)]) + case .messageActionChatJoinedByRequest: + return ("messageActionChatJoinedByRequest", []) case .messageActionPinMessage: return ("messageActionPinMessage", []) case .messageActionHistoryClear: @@ -21451,6 +21464,9 @@ public extension Api { return nil } } + public static func parse_messageActionChatJoinedByRequest(_ reader: BufferReader) -> MessageAction? { + return Api.MessageAction.messageActionChatJoinedByRequest + } public static func parse_messageActionPinMessage(_ reader: BufferReader) -> MessageAction? { return Api.MessageAction.messageActionPinMessage } diff --git a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift index c04933a70f..df871f29b4 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/StoreMessage_Telegram.swift @@ -195,7 +195,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] { } switch action { - case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme: + case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest: break case let .messageActionChannelMigrateFrom(_, chatId): result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))) diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift index df9db3bfb3..c2a1b1efdc 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaAction.swift @@ -79,6 +79,8 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe } case let .messageActionSetChatTheme(emoji): return TelegramMediaAction(action: .setChatTheme(emoji: emoji)) + case .messageActionChatJoinedByRequest: + return TelegramMediaAction(action: .joinedByRequest) } } diff --git a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift index d9ebd093fe..b0261bf8ae 100644 --- a/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift +++ b/submodules/TelegramCore/Sources/SyncCore/SyncCore_TelegramMediaAction.swift @@ -49,6 +49,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { case groupPhoneCall(callId: Int64, accessHash: Int64, scheduleDate: Int32?, duration: Int32?) case inviteToGroupPhoneCall(callId: Int64, accessHash: Int64, peerIds: [PeerId]) case setChatTheme(emoji: String) + case joinedByRequest public init(decoder: PostboxDecoder) { let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0) @@ -113,6 +114,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { self = .inviteToGroupPhoneCall(callId: decoder.decodeInt64ForKey("callId", orElse: 0), accessHash: decoder.decodeInt64ForKey("accessHash", orElse: 0), peerIds: peerIds) case 24: self = .setChatTheme(emoji: decoder.decodeStringForKey("emoji", orElse: "")) + case 25: + self = .joinedByRequest default: self = .unknown } @@ -225,6 +228,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable { case let .setChatTheme(emoji): encoder.encodeInt32(24, forKey: "_rawValue") encoder.encodeString(emoji, forKey: "emoji") + case .joinedByRequest: + encoder.encodeInt32(25, forKey: "_rawValue") } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/InvitationLinks.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/InvitationLinks.swift index 61e513748c..85b8fa9c9d 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/InvitationLinks.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/InvitationLinks.swift @@ -643,6 +643,7 @@ public struct PeerInvitationImportersState: Equatable { public struct Importer: Equatable { public var peer: RenderedPeer public var date: Int32 + public var about: String? public var approvedBy: PeerId? } public var importers: [Importer] @@ -838,15 +839,17 @@ private final class PeerInvitationImportersContextImpl { for importer in importers { let peerId: PeerId let date: Int32 + let about: String? let approvedBy: PeerId? switch importer { - case let .chatInviteImporter(_, userId, dateValue, approvedByValue): + case let .chatInviteImporter(_, userId, dateValue, aboutValue, approvedByValue): peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId)) date = dateValue + about = aboutValue approvedBy = approvedByValue.flatMap { PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) } } if let peer = transaction.getPeer(peerId) { - resultImporters.append(PeerInvitationImportersState.Importer(peer: RenderedPeer(peer: peer), date: date, approvedBy: approvedBy)) + resultImporters.append(PeerInvitationImportersState.Importer(peer: RenderedPeer(peer: peer), date: date, about: about, approvedBy: approvedBy)) } } if populateCache { diff --git a/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift b/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift index 917a4e072a..2ca54b5883 100644 --- a/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift +++ b/submodules/TelegramStringFormatting/Sources/ServiceMessageStrings.swift @@ -257,6 +257,8 @@ public func universalServiceMessageString(presentationData: (PresentationTheme, } case .joinedByLink: attributedString = addAttributesToStringWithRanges(strings.Notification_JoinedGroupByLink(authorName)._tuple, body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, message.author?.id)])) + case .joinedByRequest: + attributedString = NSAttributedString(string: isChannel ? strings.Notification_JoinedChannelByRequest : strings.Notification_JoinedGroupByRequest, font: titleFont, textColor: primaryTextColor) case .channelMigratedFromGroup, .groupMigratedToChannel: attributedString = NSAttributedString(string: "", font: titleFont, textColor: primaryTextColor) case let .messageAutoremoveTimeoutUpdated(timeout):