Update API

This commit is contained in:
Ali 2022-09-02 01:07:59 +04:00
parent 783f6db782
commit fe3715bd90
22 changed files with 158 additions and 98 deletions

View File

@ -205,6 +205,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1275374751] = { return Api.EmojiLanguage.parse_emojiLanguage($0) }
dict[-1835310691] = { return Api.EmojiStatus.parse_emojiStatus($0) }
dict[769727150] = { return Api.EmojiStatus.parse_emojiStatusEmpty($0) }
dict[-97474361] = { return Api.EmojiStatus.parse_emojiStatusUntil($0) }
dict[-1519029347] = { return Api.EmojiURL.parse_emojiURL($0) }
dict[1643173063] = { return Api.EncryptedChat.parse_encryptedChat($0) }
dict[505183301] = { return Api.EncryptedChat.parse_encryptedChatDiscarded($0) }
@ -805,6 +806,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1398708869] = { return Api.Update.parse_updateMessagePoll($0) }
dict[274961865] = { return Api.Update.parse_updateMessagePollVote($0) }
dict[357013699] = { return Api.Update.parse_updateMessageReactions($0) }
dict[-2030252155] = { return Api.Update.parse_updateMoveStickerSetToTop($0) }
dict[1656358105] = { return Api.Update.parse_updateNewChannelMessage($0) }
dict[314359194] = { return Api.Update.parse_updateNewEncryptedMessage($0) }
dict[522914557] = { return Api.Update.parse_updateNewMessage($0) }

View File

@ -805,7 +805,7 @@ public extension Api {
}
}
public extension Api {
enum BotCommandScope: TypeConstructorDescription {
indirect enum BotCommandScope: TypeConstructorDescription {
case botCommandScopeChatAdmins
case botCommandScopeChats
case botCommandScopeDefault

View File

@ -111,7 +111,7 @@ public extension Api {
}
}
public extension Api {
enum InputStorePaymentPurpose: TypeConstructorDescription {
indirect enum InputStorePaymentPurpose: TypeConstructorDescription {
case inputStorePaymentGiftPremium(userId: Api.InputUser, currency: String, amount: Int64)
case inputStorePaymentPremiumSubscription(flags: Int32)
@ -309,7 +309,7 @@ public extension Api {
}
}
public extension Api {
enum InputUser: TypeConstructorDescription {
indirect enum InputUser: TypeConstructorDescription {
case inputUser(userId: Int64, accessHash: Int64)
case inputUserEmpty
case inputUserFromMessage(peer: Api.InputPeer, msgId: Int32, userId: Int64)
@ -905,7 +905,7 @@ public extension Api {
}
}
public extension Api {
enum KeyboardButton: TypeConstructorDescription {
indirect enum KeyboardButton: TypeConstructorDescription {
case inputKeyboardButtonUrlAuth(flags: Int32, text: String, fwdText: String?, url: String, bot: Api.InputUser)
case inputKeyboardButtonUserProfile(text: String, userId: Api.InputUser)
case keyboardButton(text: String)

View File

@ -359,7 +359,7 @@ public extension Api {
}
}
public extension Api {
enum Message: TypeConstructorDescription {
indirect enum Message: TypeConstructorDescription {
case message(flags: Int32, id: Int32, fromId: Api.Peer?, peerId: Api.Peer, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int64?, replyTo: Api.MessageReplyHeader?, date: Int32, message: String, media: Api.MessageMedia?, replyMarkup: Api.ReplyMarkup?, entities: [Api.MessageEntity]?, views: Int32?, forwards: Int32?, replies: Api.MessageReplies?, editDate: Int32?, postAuthor: String?, groupedId: Int64?, reactions: Api.MessageReactions?, restrictionReason: [Api.RestrictionReason]?, ttlPeriod: Int32?)
case messageEmpty(flags: Int32, id: Int32, peerId: Api.Peer?)
case messageService(flags: Int32, id: Int32, fromId: Api.Peer?, peerId: Api.Peer, replyTo: Api.MessageReplyHeader?, date: Int32, action: Api.MessageAction, ttlPeriod: Int32?)

View File

@ -1,5 +1,5 @@
public extension Api {
enum MessageEntity: TypeConstructorDescription {
indirect enum MessageEntity: TypeConstructorDescription {
case inputMessageEntityMentionName(offset: Int32, length: Int32, userId: Api.InputUser)
case messageEntityBankCard(offset: Int32, length: Int32)
case messageEntityBlockquote(offset: Int32, length: Int32)
@ -541,7 +541,7 @@ public extension Api {
}
}
public extension Api {
enum MessageExtendedMedia: TypeConstructorDescription {
indirect enum MessageExtendedMedia: TypeConstructorDescription {
case messageExtendedMedia(media: Api.MessageMedia)
case messageExtendedMediaPreview(flags: Int32, w: Int32?, h: Int32?, thumb: Api.PhotoSize?, videoDuration: Int32?)

View File

@ -891,7 +891,7 @@ public extension Api {
}
}
public extension Api {
enum PageCaption: TypeConstructorDescription {
indirect enum PageCaption: TypeConstructorDescription {
case pageCaption(text: Api.RichText, credit: Api.RichText)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -935,7 +935,7 @@ public extension Api {
}
}
public extension Api {
enum PageListItem: TypeConstructorDescription {
indirect enum PageListItem: TypeConstructorDescription {
case pageListItemBlocks(blocks: [Api.PageBlock])
case pageListItemText(text: Api.RichText)

View File

@ -1,5 +1,5 @@
public extension Api {
enum PageListOrderedItem: TypeConstructorDescription {
indirect enum PageListOrderedItem: TypeConstructorDescription {
case pageListOrderedItemBlocks(num: String, blocks: [Api.PageBlock])
case pageListOrderedItemText(num: String, text: Api.RichText)
@ -135,7 +135,7 @@ public extension Api {
}
}
public extension Api {
enum PageTableCell: TypeConstructorDescription {
indirect enum PageTableCell: TypeConstructorDescription {
case pageTableCell(flags: Int32, text: Api.RichText?, colspan: Int32?, rowspan: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {

View File

@ -157,7 +157,7 @@ public extension Api {
}
}
public extension Api {
enum RecentMeUrl: TypeConstructorDescription {
indirect enum RecentMeUrl: TypeConstructorDescription {
case recentMeUrlChat(url: String, chatId: Int64)
case recentMeUrlChatInvite(url: String, chatInvite: Api.ChatInvite)
case recentMeUrlStickerSet(url: String, set: Api.StickerSetCovered)

View File

@ -391,7 +391,7 @@ public extension Api {
}
}
public extension Api {
enum SponsoredMessage: TypeConstructorDescription {
indirect enum SponsoredMessage: TypeConstructorDescription {
case sponsoredMessage(flags: Int32, randomId: Buffer, fromId: Api.Peer?, chatInvite: Api.ChatInvite?, chatInviteHash: String?, channelPost: Int32?, startParam: String?, message: String, entities: [Api.MessageEntity]?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {

View File

@ -555,7 +555,7 @@ public extension Api {
}
}
public extension Api {
enum ChannelAdminLogEvent: TypeConstructorDescription {
indirect enum ChannelAdminLogEvent: TypeConstructorDescription {
case channelAdminLogEvent(id: Int64, date: Int32, userId: Int64, action: Api.ChannelAdminLogEventAction)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -605,7 +605,7 @@ public extension Api {
}
}
public extension Api {
enum ChannelAdminLogEventAction: TypeConstructorDescription {
indirect enum ChannelAdminLogEventAction: TypeConstructorDescription {
case channelAdminLogEventActionChangeAbout(prevValue: String, newValue: String)
case channelAdminLogEventActionChangeAvailableReactions(prevValue: Api.ChatReactions, newValue: Api.ChatReactions)
case channelAdminLogEventActionChangeHistoryTTL(prevValue: Int32, newValue: Int32)

View File

@ -551,7 +551,7 @@ public extension Api {
}
}
public extension Api {
enum Update: TypeConstructorDescription {
indirect enum Update: TypeConstructorDescription {
case updateAttachMenuBots
case updateBotCallbackQuery(flags: Int32, queryId: Int64, userId: Int64, peer: Api.Peer, msgId: Int32, chatInstance: Int64, data: Buffer?, gameShortName: String?)
case updateBotChatInviteRequester(peer: Api.Peer, date: Int32, userId: Int64, about: String, invite: Api.ExportedChatInvite, qts: Int32)
@ -613,6 +613,7 @@ public extension Api {
case updateMessagePoll(flags: Int32, pollId: Int64, poll: Api.Poll?, results: Api.PollResults)
case updateMessagePollVote(pollId: Int64, userId: Int64, options: [Buffer], qts: Int32)
case updateMessageReactions(peer: Api.Peer, msgId: Int32, reactions: Api.MessageReactions)
case updateMoveStickerSetToTop(flags: Int32, stickerset: Int64)
case updateNewChannelMessage(message: Api.Message, pts: Int32, ptsCount: Int32)
case updateNewEncryptedMessage(message: Api.EncryptedMessage, qts: Int32)
case updateNewMessage(message: Api.Message, pts: Int32, ptsCount: Int32)
@ -1195,6 +1196,13 @@ public extension Api {
serializeInt32(msgId, buffer: buffer, boxed: false)
reactions.serialize(buffer, true)
break
case .updateMoveStickerSetToTop(let flags, let stickerset):
if boxed {
buffer.appendInt32(-2030252155)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(stickerset, buffer: buffer, boxed: false)
break
case .updateNewChannelMessage(let message, let pts, let ptsCount):
if boxed {
buffer.appendInt32(1656358105)
@ -1698,6 +1706,8 @@ public extension Api {
return ("updateMessagePollVote", [("pollId", String(describing: pollId)), ("userId", String(describing: userId)), ("options", String(describing: options)), ("qts", String(describing: qts))])
case .updateMessageReactions(let peer, let msgId, let reactions):
return ("updateMessageReactions", [("peer", String(describing: peer)), ("msgId", String(describing: msgId)), ("reactions", String(describing: reactions))])
case .updateMoveStickerSetToTop(let flags, let stickerset):
return ("updateMoveStickerSetToTop", [("flags", String(describing: flags)), ("stickerset", String(describing: stickerset))])
case .updateNewChannelMessage(let message, let pts, let ptsCount):
return ("updateNewChannelMessage", [("message", String(describing: message)), ("pts", String(describing: pts)), ("ptsCount", String(describing: ptsCount))])
case .updateNewEncryptedMessage(let message, let qts):
@ -2918,6 +2928,20 @@ public extension Api {
return nil
}
}
public static func parse_updateMoveStickerSetToTop(_ reader: BufferReader) -> Update? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int64?
_2 = reader.readInt64()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.Update.updateMoveStickerSetToTop(flags: _1!, stickerset: _2!)
}
else {
return nil
}
}
public static func parse_updateNewChannelMessage(_ reader: BufferReader) -> Update? {
var _1: Api.Message?
if let signature = reader.readInt32() {

View File

@ -1,5 +1,5 @@
public extension Api {
enum Updates: TypeConstructorDescription {
indirect enum Updates: TypeConstructorDescription {
case updateShort(update: Api.Update, date: Int32)
case updateShortChatMessage(flags: Int32, id: Int32, fromId: Int64, chatId: Int64, message: String, pts: Int32, ptsCount: Int32, date: Int32, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int64?, replyTo: Api.MessageReplyHeader?, entities: [Api.MessageEntity]?, ttlPeriod: Int32?)
case updateShortMessage(flags: Int32, id: Int32, userId: Int64, message: String, pts: Int32, ptsCount: Int32, date: Int32, fwdFrom: Api.MessageFwdHeader?, viaBotId: Int64?, replyTo: Api.MessageReplyHeader?, entities: [Api.MessageEntity]?, ttlPeriod: Int32?)

View File

@ -1281,7 +1281,7 @@ public extension Api.payments {
}
}
public extension Api.payments {
enum PaymentResult: TypeConstructorDescription {
indirect enum PaymentResult: TypeConstructorDescription {
case paymentResult(updates: Api.Updates)
case paymentVerificationNeeded(url: String)

View File

@ -521,7 +521,7 @@ public extension Api {
}
}
public extension Api {
enum Chat: TypeConstructorDescription {
indirect enum Chat: TypeConstructorDescription {
case channel(flags: Int32, id: Int64, accessHash: Int64?, title: String, username: String?, photo: Api.ChatPhoto, date: Int32, restrictionReason: [Api.RestrictionReason]?, adminRights: Api.ChatAdminRights?, bannedRights: Api.ChatBannedRights?, defaultBannedRights: Api.ChatBannedRights?, participantsCount: Int32?)
case channelForbidden(flags: Int32, id: Int64, accessHash: Int64, title: String, untilDate: Int32?)
case chat(flags: Int32, id: Int64, title: String, photo: Api.ChatPhoto, participantsCount: Int32, date: Int32, version: Int32, migratedTo: Api.InputChannel?, adminRights: Api.ChatAdminRights?, defaultBannedRights: Api.ChatBannedRights?)
@ -1205,7 +1205,7 @@ public extension Api {
}
}
public extension Api {
enum ChatInvite: TypeConstructorDescription {
indirect enum ChatInvite: TypeConstructorDescription {
case chatInvite(flags: Int32, title: String, about: String?, photo: Api.Photo, participantsCount: Int32, participants: [Api.User]?)
case chatInviteAlready(chat: Api.Chat)
case chatInvitePeek(chat: Api.Chat, expires: Int32)

View File

@ -390,6 +390,7 @@ public extension Api {
enum EmojiStatus: TypeConstructorDescription {
case emojiStatus(documentId: Int64)
case emojiStatusEmpty
case emojiStatusUntil(documentId: Int64, until: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
@ -404,6 +405,13 @@ public extension Api {
buffer.appendInt32(769727150)
}
break
case .emojiStatusUntil(let documentId, let until):
if boxed {
buffer.appendInt32(-97474361)
}
serializeInt64(documentId, buffer: buffer, boxed: false)
serializeInt32(until, buffer: buffer, boxed: false)
break
}
}
@ -414,6 +422,8 @@ public extension Api {
return ("emojiStatus", [("documentId", String(describing: documentId))])
case .emojiStatusEmpty:
return ("emojiStatusEmpty", [])
case .emojiStatusUntil(let documentId, let until):
return ("emojiStatusUntil", [("documentId", String(describing: documentId)), ("until", String(describing: until))])
}
}
@ -431,6 +441,20 @@ public extension Api {
public static func parse_emojiStatusEmpty(_ reader: BufferReader) -> EmojiStatus? {
return Api.EmojiStatus.emojiStatusEmpty
}
public static func parse_emojiStatusUntil(_ reader: BufferReader) -> EmojiStatus? {
var _1: Int64?
_1 = reader.readInt64()
var _2: Int32?
_2 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
if _c1 && _c2 {
return Api.EmojiStatus.emojiStatusUntil(documentId: _1!, until: _2!)
}
else {
return nil
}
}
}
}
@ -1136,67 +1160,3 @@ public extension Api {
}
}
public extension Api {
enum GeoPoint: TypeConstructorDescription {
case geoPoint(flags: Int32, long: Double, lat: Double, accessHash: Int64, accuracyRadius: Int32?)
case geoPointEmpty
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .geoPoint(let flags, let long, let lat, let accessHash, let accuracyRadius):
if boxed {
buffer.appendInt32(-1297942941)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeDouble(long, buffer: buffer, boxed: false)
serializeDouble(lat, buffer: buffer, boxed: false)
serializeInt64(accessHash, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(accuracyRadius!, buffer: buffer, boxed: false)}
break
case .geoPointEmpty:
if boxed {
buffer.appendInt32(286776671)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .geoPoint(let flags, let long, let lat, let accessHash, let accuracyRadius):
return ("geoPoint", [("flags", String(describing: flags)), ("long", String(describing: long)), ("lat", String(describing: lat)), ("accessHash", String(describing: accessHash)), ("accuracyRadius", String(describing: accuracyRadius))])
case .geoPointEmpty:
return ("geoPointEmpty", [])
}
}
public static func parse_geoPoint(_ reader: BufferReader) -> GeoPoint? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Double?
_2 = reader.readDouble()
var _3: Double?
_3 = reader.readDouble()
var _4: Int64?
_4 = reader.readInt64()
var _5: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.GeoPoint.geoPoint(flags: _1!, long: _2!, lat: _3!, accessHash: _4!, accuracyRadius: _5)
}
else {
return nil
}
}
public static func parse_geoPointEmpty(_ reader: BufferReader) -> GeoPoint? {
return Api.GeoPoint.geoPointEmpty
}
}
}

View File

@ -1,3 +1,67 @@
public extension Api {
enum GeoPoint: TypeConstructorDescription {
case geoPoint(flags: Int32, long: Double, lat: Double, accessHash: Int64, accuracyRadius: Int32?)
case geoPointEmpty
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .geoPoint(let flags, let long, let lat, let accessHash, let accuracyRadius):
if boxed {
buffer.appendInt32(-1297942941)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeDouble(long, buffer: buffer, boxed: false)
serializeDouble(lat, buffer: buffer, boxed: false)
serializeInt64(accessHash, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(accuracyRadius!, buffer: buffer, boxed: false)}
break
case .geoPointEmpty:
if boxed {
buffer.appendInt32(286776671)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .geoPoint(let flags, let long, let lat, let accessHash, let accuracyRadius):
return ("geoPoint", [("flags", String(describing: flags)), ("long", String(describing: long)), ("lat", String(describing: lat)), ("accessHash", String(describing: accessHash)), ("accuracyRadius", String(describing: accuracyRadius))])
case .geoPointEmpty:
return ("geoPointEmpty", [])
}
}
public static func parse_geoPoint(_ reader: BufferReader) -> GeoPoint? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Double?
_2 = reader.readDouble()
var _3: Double?
_3 = reader.readDouble()
var _4: Int64?
_4 = reader.readInt64()
var _5: Int32?
if Int(_1!) & Int(1 << 0) != 0 {_5 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.GeoPoint.geoPoint(flags: _1!, long: _2!, lat: _3!, accessHash: _4!, accuracyRadius: _5)
}
else {
return nil
}
}
public static func parse_geoPointEmpty(_ reader: BufferReader) -> GeoPoint? {
return Api.GeoPoint.geoPointEmpty
}
}
}
public extension Api {
enum GlobalPrivacySettings: TypeConstructorDescription {
case globalPrivacySettings(flags: Int32, archiveAndMuteNewNoncontactPeers: Api.Bool?)
@ -1201,7 +1265,7 @@ public extension Api {
}
}
public extension Api {
enum InputChannel: TypeConstructorDescription {
indirect enum InputChannel: TypeConstructorDescription {
case inputChannel(channelId: Int64, accessHash: Int64)
case inputChannelEmpty
case inputChannelFromMessage(peer: Api.InputPeer, msgId: Int32, channelId: Int64)

View File

@ -229,7 +229,7 @@ public extension Api {
}
}
public extension Api {
enum InputDialogPeer: TypeConstructorDescription {
indirect enum InputDialogPeer: TypeConstructorDescription {
case inputDialogPeer(peer: Api.InputPeer)
case inputDialogPeerFolder(folderId: Int32)
@ -571,7 +571,7 @@ public extension Api {
}
}
public extension Api {
enum InputFileLocation: TypeConstructorDescription {
indirect enum InputFileLocation: TypeConstructorDescription {
case inputDocumentFileLocation(id: Int64, accessHash: Int64, fileReference: Buffer, thumbSize: String)
case inputEncryptedFileLocation(id: Int64, accessHash: Int64)
case inputFileLocation(volumeId: Int64, localId: Int32, secret: Int64, fileReference: Buffer)
@ -881,7 +881,7 @@ public extension Api {
}
}
public extension Api {
enum InputFolderPeer: TypeConstructorDescription {
indirect enum InputFolderPeer: TypeConstructorDescription {
case inputFolderPeer(peer: Api.InputPeer, folderId: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
@ -923,7 +923,7 @@ public extension Api {
}
}
public extension Api {
enum InputGame: TypeConstructorDescription {
indirect enum InputGame: TypeConstructorDescription {
case inputGameID(id: Int64, accessHash: Int64)
case inputGameShortName(botId: Api.InputUser, shortName: String)

View File

@ -39,7 +39,7 @@ public extension Api {
}
}
public extension Api {
enum InputInvoice: TypeConstructorDescription {
indirect enum InputInvoice: TypeConstructorDescription {
case inputInvoiceMessage(peer: Api.InputPeer, msgId: Int32)
case inputInvoiceSlug(slug: String)
@ -731,7 +731,7 @@ public extension Api {
}
}
public extension Api {
enum InputNotifyPeer: TypeConstructorDescription {
indirect enum InputNotifyPeer: TypeConstructorDescription {
case inputNotifyBroadcasts
case inputNotifyChats
case inputNotifyPeer(peer: Api.InputPeer)

View File

@ -613,7 +613,7 @@ public extension Api {
}
}
public extension Api {
enum InputSingleMedia: TypeConstructorDescription {
indirect enum InputSingleMedia: TypeConstructorDescription {
case inputSingleMedia(flags: Int32, media: Api.InputMedia, randomId: Int64, message: String, entities: [Api.MessageEntity]?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {

View File

@ -88,9 +88,11 @@ public struct CachedPremiumGiftOption: Equatable, PostboxCoding {
public struct PeerEmojiStatus: Equatable, Codable {
public var fileId: Int64
public var expirationDate: Int32?
public init(fileId: Int64) {
public init(fileId: Int64, expirationDate: Int32?) {
self.fileId = fileId
self.expirationDate = expirationDate
}
}
@ -98,7 +100,9 @@ extension PeerEmojiStatus {
init?(apiStatus: Api.EmojiStatus) {
switch apiStatus {
case let .emojiStatus(documentId):
self.init(fileId: documentId)
self.init(fileId: documentId, expirationDate: nil)
case let .emojiStatusUntil(documentId, until):
self.init(fileId: documentId, expirationDate: until)
case .emojiStatusEmpty:
return nil
}

View File

@ -55,10 +55,16 @@ public extension TelegramEngine {
return _internal_removeAccountPhoto(network: self.account.network, reference: reference)
}
public func setEmojiStatus(file: TelegramMediaFile?) -> Signal<Never, NoError> {
public func setEmojiStatus(file: TelegramMediaFile?, expirationDate: Int32?) -> Signal<Never, NoError> {
let peerId = self.account.peerId
let remoteApply = self.account.network.request(Api.functions.account.updateEmojiStatus(emojiStatus: file.flatMap({ Api.EmojiStatus.emojiStatus(documentId: $0.fileId.id) }) ?? Api.EmojiStatus.emojiStatusEmpty))
let remoteApply = self.account.network.request(Api.functions.account.updateEmojiStatus(emojiStatus: file.flatMap({ file in
if let expirationDate = expirationDate {
return Api.EmojiStatus.emojiStatusUntil(documentId: file.fileId.id, until: expirationDate)
} else {
return Api.EmojiStatus.emojiStatus(documentId: file.fileId.id)
}
}) ?? Api.EmojiStatus.emojiStatusEmpty))
|> `catch` { _ -> Signal<Api.Bool, NoError> in
return .single(.boolFalse)
}
@ -75,7 +81,7 @@ public extension TelegramEngine {
}
if let peer = transaction.getPeer(peerId) as? TelegramUser {
updatePeers(transaction: transaction, peers: [peer.withUpdatedEmojiStatus(file.flatMap({ PeerEmojiStatus(fileId: $0.fileId.id) }))], update: { _, updated in
updatePeers(transaction: transaction, peers: [peer.withUpdatedEmojiStatus(file.flatMap({ PeerEmojiStatus(fileId: $0.fileId.id, expirationDate: expirationDate) }))], update: { _, updated in
updated
})
}

View File

@ -745,7 +745,7 @@ public final class EmojiStatusSelectionController: ViewController {
switch controller.mode {
case .statusSelection:
let _ = (self.context.engine.accountData.setEmojiStatus(file: item?.itemFile)
let _ = (self.context.engine.accountData.setEmojiStatus(file: item?.itemFile, expirationDate: nil)
|> deliverOnMainQueue).start()
case let .quickReactionSelection(completion):
if let item = item, let itemFile = item.itemFile {