Update API

This commit is contained in:
Ilya Laktyushin 2023-11-09 03:25:45 +04:00
parent 145c674185
commit 65ffd81904
10 changed files with 42 additions and 20 deletions

View File

@ -10464,3 +10464,6 @@ Sorry for the inconvenience.";
"BoostGift.StartConfirmation.Start" = "Start"; "BoostGift.StartConfirmation.Start" = "Start";
"Channel.Info.Stats" = "Statistics and Boosts"; "Channel.Info.Stats" = "Statistics and Boosts";
"Notification.GiveawayResults_1" = "%@ winner of the giveaway was randomly selected by Telegram and received private message with giftcode.";
"Notification.GiveawayResults_any" = "%@ winners of the giveaway were randomly selected by Telegram and received private messages with giftcodes.";

View File

@ -490,6 +490,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-758129906] = { return Api.MessageAction.parse_messageActionGiftCode($0) } dict[-758129906] = { return Api.MessageAction.parse_messageActionGiftCode($0) }
dict[-935499028] = { return Api.MessageAction.parse_messageActionGiftPremium($0) } dict[-935499028] = { return Api.MessageAction.parse_messageActionGiftPremium($0) }
dict[858499565] = { return Api.MessageAction.parse_messageActionGiveawayLaunch($0) } dict[858499565] = { return Api.MessageAction.parse_messageActionGiveawayLaunch($0) }
dict[1927497572] = { return Api.MessageAction.parse_messageActionGiveawayResults($0) }
dict[2047704898] = { return Api.MessageAction.parse_messageActionGroupCall($0) } dict[2047704898] = { return Api.MessageAction.parse_messageActionGroupCall($0) }
dict[-1281329567] = { return Api.MessageAction.parse_messageActionGroupCallScheduled($0) } dict[-1281329567] = { return Api.MessageAction.parse_messageActionGroupCallScheduled($0) }
dict[-1615153660] = { return Api.MessageAction.parse_messageActionHistoryClear($0) } dict[-1615153660] = { return Api.MessageAction.parse_messageActionHistoryClear($0) }

View File

@ -612,6 +612,7 @@ public extension Api {
case messageActionGiftCode(flags: Int32, boostPeer: Api.Peer?, months: Int32, slug: String) case messageActionGiftCode(flags: Int32, boostPeer: Api.Peer?, months: Int32, slug: String)
case messageActionGiftPremium(flags: Int32, currency: String, amount: Int64, months: Int32, cryptoCurrency: String?, cryptoAmount: Int64?) case messageActionGiftPremium(flags: Int32, currency: String, amount: Int64, months: Int32, cryptoCurrency: String?, cryptoAmount: Int64?)
case messageActionGiveawayLaunch case messageActionGiveawayLaunch
case messageActionGiveawayResults(winnersCount: Int32)
case messageActionGroupCall(flags: Int32, call: Api.InputGroupCall, duration: Int32?) case messageActionGroupCall(flags: Int32, call: Api.InputGroupCall, duration: Int32?)
case messageActionGroupCallScheduled(call: Api.InputGroupCall, scheduleDate: Int32) case messageActionGroupCallScheduled(call: Api.InputGroupCall, scheduleDate: Int32)
case messageActionHistoryClear case messageActionHistoryClear
@ -778,6 +779,12 @@ public extension Api {
buffer.appendInt32(858499565) buffer.appendInt32(858499565)
} }
break
case .messageActionGiveawayResults(let winnersCount):
if boxed {
buffer.appendInt32(1927497572)
}
serializeInt32(winnersCount, buffer: buffer, boxed: false)
break break
case .messageActionGroupCall(let flags, let call, let duration): case .messageActionGroupCall(let flags, let call, let duration):
if boxed { if boxed {
@ -990,6 +997,8 @@ public extension Api {
return ("messageActionGiftPremium", [("flags", flags as Any), ("currency", currency as Any), ("amount", amount as Any), ("months", months as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any)]) return ("messageActionGiftPremium", [("flags", flags as Any), ("currency", currency as Any), ("amount", amount as Any), ("months", months as Any), ("cryptoCurrency", cryptoCurrency as Any), ("cryptoAmount", cryptoAmount as Any)])
case .messageActionGiveawayLaunch: case .messageActionGiveawayLaunch:
return ("messageActionGiveawayLaunch", []) return ("messageActionGiveawayLaunch", [])
case .messageActionGiveawayResults(let winnersCount):
return ("messageActionGiveawayResults", [("winnersCount", winnersCount as Any)])
case .messageActionGroupCall(let flags, let call, let duration): case .messageActionGroupCall(let flags, let call, let duration):
return ("messageActionGroupCall", [("flags", flags as Any), ("call", call as Any), ("duration", duration as Any)]) return ("messageActionGroupCall", [("flags", flags as Any), ("call", call as Any), ("duration", duration as Any)])
case .messageActionGroupCallScheduled(let call, let scheduleDate): case .messageActionGroupCallScheduled(let call, let scheduleDate):
@ -1274,6 +1283,17 @@ public extension Api {
public static func parse_messageActionGiveawayLaunch(_ reader: BufferReader) -> MessageAction? { public static func parse_messageActionGiveawayLaunch(_ reader: BufferReader) -> MessageAction? {
return Api.MessageAction.messageActionGiveawayLaunch return Api.MessageAction.messageActionGiveawayLaunch
} }
public static func parse_messageActionGiveawayResults(_ reader: BufferReader) -> MessageAction? {
var _1: Int32?
_1 = reader.readInt32()
let _c1 = _1 != nil
if _c1 {
return Api.MessageAction.messageActionGiveawayResults(winnersCount: _1!)
}
else {
return nil
}
}
public static func parse_messageActionGroupCall(_ reader: BufferReader) -> MessageAction? { public static func parse_messageActionGroupCall(_ reader: BufferReader) -> MessageAction? {
var _1: Int32? var _1: Int32?
_1 = reader.readInt32() _1 = reader.readInt32()

View File

@ -217,7 +217,7 @@ func apiMessagePeerIds(_ message: Api.Message) -> [PeerId] {
} }
switch action { switch action {
case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionSetSameChatWallPaper, .messageActionGiveawayLaunch: case .messageActionChannelCreate, .messageActionChatDeletePhoto, .messageActionChatEditPhoto, .messageActionChatEditTitle, .messageActionEmpty, .messageActionPinMessage, .messageActionHistoryClear, .messageActionGameScore, .messageActionPaymentSent, .messageActionPaymentSentMe, .messageActionPhoneCall, .messageActionScreenshotTaken, .messageActionCustomAction, .messageActionBotAllowed, .messageActionSecureValuesSent, .messageActionSecureValuesSentMe, .messageActionContactSignUp, .messageActionGroupCall, .messageActionSetMessagesTTL, .messageActionGroupCallScheduled, .messageActionSetChatTheme, .messageActionChatJoinedByRequest, .messageActionWebViewDataSent, .messageActionWebViewDataSentMe, .messageActionGiftPremium, .messageActionTopicCreate, .messageActionTopicEdit, .messageActionSuggestProfilePhoto, .messageActionSetChatWallPaper, .messageActionSetSameChatWallPaper, .messageActionGiveawayLaunch, .messageActionGiveawayResults:
break break
case let .messageActionChannelMigrateFrom(_, chatId): case let .messageActionChannelMigrateFrom(_, chatId):
result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId))) result.append(PeerId(namespace: Namespaces.Peer.CloudGroup, id: PeerId.Id._internalFromInt64Value(chatId)))

View File

@ -131,6 +131,8 @@ func telegramMediaActionFromApiAction(_ action: Api.MessageAction) -> TelegramMe
return TelegramMediaAction(action: .giftCode(slug: slug, fromGiveaway: (flags & (1 << 0)) != 0, isUnclaimed: (flags & (1 << 2)) != 0, boostPeerId: boostPeer?.peerId, months: months)) return TelegramMediaAction(action: .giftCode(slug: slug, fromGiveaway: (flags & (1 << 0)) != 0, isUnclaimed: (flags & (1 << 2)) != 0, boostPeerId: boostPeer?.peerId, months: months))
case .messageActionGiveawayLaunch: case .messageActionGiveawayLaunch:
return TelegramMediaAction(action: .giveawayLaunched) return TelegramMediaAction(action: .giveawayLaunched)
case let .messageActionGiveawayResults(winners):
return TelegramMediaAction(action: .giveawayResults(winners: winners))
} }
} }

View File

@ -112,6 +112,7 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
case giftCode(slug: String, fromGiveaway: Bool, isUnclaimed: Bool, boostPeerId: PeerId?, months: Int32) case giftCode(slug: String, fromGiveaway: Bool, isUnclaimed: Bool, boostPeerId: PeerId?, months: Int32)
case giveawayLaunched case giveawayLaunched
case joinedChannel case joinedChannel
case giveawayResults(winners: Int32)
public init(decoder: PostboxDecoder) { public init(decoder: PostboxDecoder) {
let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0) let rawValue: Int32 = decoder.decodeInt32ForKey("_rawValue", orElse: 0)
@ -212,6 +213,8 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
self = .giveawayLaunched self = .giveawayLaunched
case 38: case 38:
self = .joinedChannel self = .joinedChannel
case 39:
self = .giveawayResults(winners: decoder.decodeInt32ForKey("winners", orElse: 0))
default: default:
self = .unknown self = .unknown
} }
@ -406,6 +409,9 @@ public enum TelegramMediaActionType: PostboxCoding, Equatable {
encoder.encodeInt32(37, forKey: "_rawValue") encoder.encodeInt32(37, forKey: "_rawValue")
case .joinedChannel: case .joinedChannel:
encoder.encodeInt32(38, forKey: "_rawValue") encoder.encodeInt32(38, forKey: "_rawValue")
case let .giveawayResults(winners):
encoder.encodeInt32(39, forKey: "_rawValue")
encoder.encodeInt32(winners, forKey: "winners")
} }
} }

View File

@ -905,6 +905,8 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
attributedString = addAttributesToStringWithRanges(resultTitleString._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes]) attributedString = addAttributesToStringWithRanges(resultTitleString._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
case .joinedChannel: case .joinedChannel:
attributedString = NSAttributedString(string: strings.Notification_ChannelJoinedByYou, font: titleBoldFont, textColor: primaryTextColor) attributedString = NSAttributedString(string: strings.Notification_ChannelJoinedByYou, font: titleBoldFont, textColor: primaryTextColor)
case let .giveawayResults(winners):
attributedString = NSAttributedString(string: strings.Notification_GiveawayResults(winners), font: titleFont, textColor: primaryTextColor)
case .unknown: case .unknown:
attributedString = nil attributedString = nil
} }

View File

@ -227,11 +227,9 @@ public class ChatMessageActionBubbleContentNode: ChatMessageBubbleContentNode {
} }
var backgroundSize = CGSize(width: labelLayout.size.width + 8.0 + 8.0, height: labelLayout.size.height + 4.0) var backgroundSize = CGSize(width: labelLayout.size.width + 8.0 + 8.0, height: labelLayout.size.height + 4.0)
if let _ = image { if let _ = image {
backgroundSize.height += imageSize.height + 10 backgroundSize.height += imageSize.height + 10
} }
return (backgroundSize.width, { boundingWidth in return (backgroundSize.width, { boundingWidth in
return (backgroundSize, { [weak self] animation, synchronousLoads, _ in return (backgroundSize, { [weak self] animation, synchronousLoads, _ in
if let strongSelf = self { if let strongSelf = self {

View File

@ -791,7 +791,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return false return false
} }
switch action.action { switch action.action {
case .pinnedMessageUpdated: case .pinnedMessageUpdated, .gameScore, .setSameChatWallpaper, .giveawayResults:
for attribute in message.attributes { for attribute in message.attributes {
if let attribute = attribute as? ReplyMessageAttribute { if let attribute = attribute as? ReplyMessageAttribute {
strongSelf.navigateToMessage(from: message.id, to: .id(attribute.messageId, NavigateToMessageParams(timestamp: nil, quote: attribute.isQuote ? attribute.quote.flatMap { quote in NavigateToMessageParams.Quote(string: quote.text, offset: quote.offset) } : nil))) strongSelf.navigateToMessage(from: message.id, to: .id(attribute.messageId, NavigateToMessageParams(timestamp: nil, quote: attribute.isQuote ? attribute.quote.flatMap { quote in NavigateToMessageParams.Quote(string: quote.text, offset: quote.offset) } : nil)))
@ -800,13 +800,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
case let .photoUpdated(image): case let .photoUpdated(image):
openMessageByAction = image != nil openMessageByAction = image != nil
case .gameScore:
for attribute in message.attributes {
if let attribute = attribute as? ReplyMessageAttribute {
strongSelf.navigateToMessage(from: message.id, to: .id(attribute.messageId, NavigateToMessageParams(timestamp: nil, quote: attribute.isQuote ? attribute.quote.flatMap { quote in NavigateToMessageParams.Quote(string: quote.text, offset: quote.offset) } : nil)))
break
}
}
case .groupPhoneCall, .inviteToGroupPhoneCall: case .groupPhoneCall, .inviteToGroupPhoneCall:
if let activeCall = strongSelf.presentationInterfaceState.activeGroupCallInfo?.activeCall { if let activeCall = strongSelf.presentationInterfaceState.activeGroupCallInfo?.activeCall {
strongSelf.joinGroupCall(peerId: message.id.peerId, invite: nil, activeCall: EngineGroupCallDescription(id: activeCall.id, accessHash: activeCall.accessHash, title: activeCall.title, scheduleTimestamp: activeCall.scheduleTimestamp, subscribedToScheduled: activeCall.subscribedToScheduled, isStream: activeCall.isStream)) strongSelf.joinGroupCall(peerId: message.id.peerId, invite: nil, activeCall: EngineGroupCallDescription(id: activeCall.id, accessHash: activeCall.accessHash, title: activeCall.title, scheduleTimestamp: activeCall.scheduleTimestamp, subscribedToScheduled: activeCall.subscribedToScheduled, isStream: activeCall.isStream))
@ -955,13 +948,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
strongSelf.push(wallpaperPreviewController) strongSelf.push(wallpaperPreviewController)
return true return true
case .setSameChatWallpaper:
for attribute in message.attributes {
if let attribute = attribute as? ReplyMessageAttribute {
strongSelf.controllerInteraction?.navigateToMessage(message.id, attribute.messageId, NavigateToMessageParams(timestamp: nil, quote: nil))
return true
}
}
case let .giftPremium(_, _, duration, _, _): case let .giftPremium(_, _, duration, _, _):
strongSelf.chatDisplayNode.dismissInput() strongSelf.chatDisplayNode.dismissInput()
let fromPeerId: PeerId = message.author?.id == strongSelf.context.account.peerId ? strongSelf.context.account.peerId : message.id.peerId let fromPeerId: PeerId = message.author?.id == strongSelf.context.account.peerId ? strongSelf.context.account.peerId : message.id.peerId

View File

@ -1097,7 +1097,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
self.panelNode.backgroundColor = .clear self.panelNode.backgroundColor = .clear
} }
self.panelNode.clipsToBounds = true self.panelNode.clipsToBounds = true
self.panelNode.cornerRadius = 9.0 self.panelNode.cornerRadius = 14.0
self.panelWrapperNode = ASDisplayNode() self.panelWrapperNode = ASDisplayNode()
@ -1184,6 +1184,10 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode {
override func didLoad() { override func didLoad() {
super.didLoad() super.didLoad()
if #available(iOS 13.0, *) {
self.panelNode.layer.cornerCurve = .continuous
}
self.panelNode.view.addSubview(self.effectView) self.panelNode.view.addSubview(self.effectView)
} }