mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Add support for multiple users selection in bots peer requests
This commit is contained in:
@@ -231,7 +231,7 @@ public enum ReplyMarkupButtonAction: PostboxCoding, Equatable {
|
||||
case setupPoll(isQuiz: Bool?)
|
||||
case openUserProfile(peerId: PeerId)
|
||||
case openWebView(url: String, simple: Bool)
|
||||
case requestPeer(peerType: ReplyMarkupButtonRequestPeerType, buttonId: Int32)
|
||||
case requestPeer(peerType: ReplyMarkupButtonRequestPeerType, buttonId: Int32, maxQuantity: Int32)
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
switch decoder.decodeInt32ForKey("v", orElse: 0) {
|
||||
@@ -260,7 +260,7 @@ public enum ReplyMarkupButtonAction: PostboxCoding, Equatable {
|
||||
case 11:
|
||||
self = .openWebView(url: decoder.decodeStringForKey("u", orElse: ""), simple: decoder.decodeInt32ForKey("s", orElse: 0) != 0)
|
||||
case 12:
|
||||
self = .requestPeer(peerType: decoder.decode(ReplyMarkupButtonRequestPeerType.self, forKey: "pt") ?? ReplyMarkupButtonRequestPeerType.user(ReplyMarkupButtonRequestPeerType.User(isBot: nil, isPremium: nil)), buttonId: decoder.decodeInt32ForKey("b", orElse: 0))
|
||||
self = .requestPeer(peerType: decoder.decode(ReplyMarkupButtonRequestPeerType.self, forKey: "pt") ?? ReplyMarkupButtonRequestPeerType.user(ReplyMarkupButtonRequestPeerType.User(isBot: nil, isPremium: nil)), buttonId: decoder.decodeInt32ForKey("b", orElse: 0), maxQuantity: decoder.decodeInt32ForKey("q", orElse: 1))
|
||||
default:
|
||||
self = .text
|
||||
}
|
||||
@@ -308,10 +308,11 @@ public enum ReplyMarkupButtonAction: PostboxCoding, Equatable {
|
||||
encoder.encodeInt32(11, forKey: "v")
|
||||
encoder.encodeString(url, forKey: "u")
|
||||
encoder.encodeInt32(simple ? 1 : 0, forKey: "s")
|
||||
case let .requestPeer(peerType, buttonId):
|
||||
case let .requestPeer(peerType, buttonId, maxQuantity):
|
||||
encoder.encodeInt32(12, forKey: "v")
|
||||
encoder.encodeInt32(buttonId, forKey: "b")
|
||||
encoder.encode(peerType, forKey: "pt")
|
||||
encoder.encodeInt32(maxQuantity, forKey: "q")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
case topicEdited(components: [ForumTopicEditComponent])
|
||||
case suggestedProfilePhoto(image: TelegramMediaImage?)
|
||||
case attachMenuBotAllowed
|
||||
case requestedPeer(buttonId: Int32, peerId: PeerId)
|
||||
case requestedPeer(buttonId: Int32, peerIds: [PeerId])
|
||||
case setChatWallpaper(wallpaper: TelegramWallpaper, forBoth: Bool)
|
||||
case setSameChatWallpaper(wallpaper: TelegramWallpaper)
|
||||
case giftCode(slug: String, fromGiveaway: Bool, isUnclaimed: Bool, boostPeerId: PeerId?, months: Int32, currency: String?, amount: Int64?, cryptoCurrency: String?, cryptoAmount: Int64?)
|
||||
@@ -205,7 +205,11 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
case 31:
|
||||
self = .attachMenuBotAllowed
|
||||
case 32:
|
||||
self = .requestedPeer(buttonId: decoder.decodeInt32ForKey("b", orElse: 0), peerId: PeerId(decoder.decodeInt64ForKey("pi", orElse: 0)))
|
||||
var peerIds = decoder.decodeInt64ArrayForKey("pis").map { PeerId($0) }
|
||||
if peerIds.isEmpty {
|
||||
peerIds = [PeerId(decoder.decodeInt64ForKey("pi", orElse: 0))]
|
||||
}
|
||||
self = .requestedPeer(buttonId: decoder.decodeInt32ForKey("b", orElse: 0), peerIds: peerIds)
|
||||
case 33:
|
||||
if let wallpaper = decoder.decode(TelegramWallpaperNativeCodable.self, forKey: "wallpaper")?.value {
|
||||
self = .setChatWallpaper(wallpaper: wallpaper, forBoth: decoder.decodeBoolForKey("both", orElse: false))
|
||||
@@ -385,10 +389,10 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
}
|
||||
case .attachMenuBotAllowed:
|
||||
encoder.encodeInt32(31, forKey: "_rawValue")
|
||||
case let .requestedPeer(buttonId, peerId):
|
||||
case let .requestedPeer(buttonId, peerIds):
|
||||
encoder.encodeInt32(32, forKey: "_rawValue")
|
||||
encoder.encodeInt32(buttonId, forKey: "b")
|
||||
encoder.encodeInt64(peerId.toInt64(), forKey: "pi")
|
||||
encoder.encodeInt64Array(peerIds.map { $0.toInt64() }, forKey: "pis")
|
||||
case let .setChatWallpaper(wallpaper, forBoth):
|
||||
encoder.encodeInt32(33, forKey: "_rawValue")
|
||||
encoder.encode(TelegramWallpaperNativeCodable(wallpaper), forKey: "wallpaper")
|
||||
@@ -466,8 +470,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
return [from, to]
|
||||
case let .inviteToGroupPhoneCall(_, _, peerIds):
|
||||
return peerIds
|
||||
case let .requestedPeer(_, peerId):
|
||||
return [peerId]
|
||||
case let .requestedPeer(_, peerIds):
|
||||
return peerIds
|
||||
case let .giftCode(_, _, _, boostPeerId, _, _, _, _, _):
|
||||
return boostPeerId.flatMap { [$0] } ?? []
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user