Skip to content

Commit 3c29287

Browse files
committed
API update
1 parent 67e13e5 commit 3c29287

10 files changed

Lines changed: 120 additions & 50 deletions

‎submodules/TelegramApi/Sources/Api0.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
538538
dict[-4838507] = { return Api.InputStickerSet.parse_inputStickerSetEmpty($0) }
539539
dict[-1645763991] = { return Api.InputStickerSet.parse_inputStickerSetID($0) }
540540
dict[-2044933984] = { return Api.InputStickerSet.parse_inputStickerSetShortName($0) }
541+
dict[42402760] = { return Api.InputStickerSet.parse_inputStickerSetAnimatedEmoji($0) }
541542
dict[-1729618630] = { return Api.BotInfo.parse_botInfo($0) }
542543
dict[-1519637954] = { return Api.updates.State.parse_state($0) }
543544
dict[372165663] = { return Api.FoundGif.parse_foundGif($0) }

‎submodules/TelegramApi/Sources/Api1.swift‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13607,6 +13607,7 @@ public extension Api {
1360713607
case inputStickerSetEmpty
1360813608
case inputStickerSetID(id: Int64, accessHash: Int64)
1360913609
case inputStickerSetShortName(shortName: String)
13610+
case inputStickerSetAnimatedEmoji
1361013611

1361113612
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
1361213613
switch self {
@@ -13628,6 +13629,12 @@ public extension Api {
1362813629
buffer.appendInt32(-2044933984)
1362913630
}
1363013631
serializeString(shortName, buffer: buffer, boxed: false)
13632+
break
13633+
case .inputStickerSetAnimatedEmoji:
13634+
if boxed {
13635+
buffer.appendInt32(42402760)
13636+
}
13637+
1363113638
break
1363213639
}
1363313640
}
@@ -13640,6 +13647,8 @@ public extension Api {
1364013647
return ("inputStickerSetID", [("id", id), ("accessHash", accessHash)])
1364113648
case .inputStickerSetShortName(let shortName):
1364213649
return ("inputStickerSetShortName", [("shortName", shortName)])
13650+
case .inputStickerSetAnimatedEmoji:
13651+
return ("inputStickerSetAnimatedEmoji", [])
1364313652
}
1364413653
}
1364513654

@@ -13671,6 +13680,9 @@ public extension Api {
1367113680
return nil
1367213681
}
1367313682
}
13683+
public static func parse_inputStickerSetAnimatedEmoji(_ reader: BufferReader) -> InputStickerSet? {
13684+
return Api.InputStickerSet.inputStickerSetAnimatedEmoji
13685+
}
1367413686

1367513687
}
1367613688
public enum BotInfo: TypeConstructorDescription {

‎submodules/TelegramCore/TelegramCore/CachedStickerPack.swift‎

Lines changed: 72 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ public enum CachedStickerPackResult {
5454
case result(StickerPackCollectionInfo, [ItemCollectionItem], Bool)
5555
}
5656

57-
func cacheStickerPack(transaction: Transaction, info: StickerPackCollectionInfo, items: [ItemCollectionItem]) {
57+
func cacheStickerPack(transaction: Transaction, info: StickerPackCollectionInfo, items: [ItemCollectionItem], reference: StickerPackReference? = nil) {
5858
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(info.id)), entry: CachedStickerPack(info: info, items: items.map { $0 as! StickerPackItem }, hash: info.hash), collectionSpec: collectionSpec)
5959
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(shortName: info.shortName)), entry: CachedStickerPack(info: info, items: items.map { $0 as! StickerPackItem }, hash: info.hash), collectionSpec: collectionSpec)
60+
61+
if let reference = reference, case .animatedEmoji = reference {
62+
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: Namespaces.ItemCollection.CloudAnimatedEmoji, id: 0))), entry: CachedStickerPack(info: info, items: items.map { $0 as! StickerPackItem }, hash: info.hash), collectionSpec: collectionSpec)
63+
}
6064
}
6165

6266
public func cachedStickerPack(postbox: Postbox, network: Network, reference: StickerPackReference, forceRemote: Bool) -> Signal<CachedStickerPackResult, NoError> {
@@ -76,30 +80,44 @@ public func cachedStickerPack(postbox: Postbox, network: Network, reference: Sti
7680
let namespace = Namespaces.ItemCollection.CloudStickerPacks
7781
var previousHash: Int32?
7882
switch reference {
79-
case let .id(id, _):
80-
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id)))) as? CachedStickerPack, let info = cached.info {
81-
previousHash = cached.hash
82-
let current: CachedStickerPackResult = .result(info, cached.items, false)
83-
if cached.hash != info.hash {
84-
return (current, true, previousHash)
83+
case let .id(id, _):
84+
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id)))) as? CachedStickerPack, let info = cached.info {
85+
previousHash = cached.hash
86+
let current: CachedStickerPackResult = .result(info, cached.items, false)
87+
if cached.hash != info.hash {
88+
return (current, true, previousHash)
89+
} else {
90+
return (current, true, previousHash)
91+
}
8592
} else {
86-
return (current, true, previousHash)
93+
return (.fetching, true, nil)
8794
}
88-
} else {
89-
return (.fetching, true, nil)
90-
}
91-
case let .name(shortName):
92-
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(shortName: shortName))) as? CachedStickerPack, let info = cached.info {
93-
previousHash = cached.hash
94-
let current: CachedStickerPackResult = .result(info, cached.items, false)
95-
if cached.hash != info.hash {
96-
return (current, true, previousHash)
95+
case let .name(shortName):
96+
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(shortName: shortName))) as? CachedStickerPack, let info = cached.info {
97+
previousHash = cached.hash
98+
let current: CachedStickerPackResult = .result(info, cached.items, false)
99+
if cached.hash != info.hash {
100+
return (current, true, previousHash)
101+
} else {
102+
return (current, true, previousHash)
103+
}
97104
} else {
98-
return (current, true, previousHash)
105+
return (.fetching, true, nil)
106+
}
107+
case .animatedEmoji:
108+
let namespace = Namespaces.ItemCollection.CloudAnimatedEmoji
109+
let id: ItemCollectionId.Id = 0
110+
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id)))) as? CachedStickerPack, let info = cached.info {
111+
previousHash = cached.hash
112+
let current: CachedStickerPackResult = .result(info, cached.items, false)
113+
if cached.hash != info.hash {
114+
return (current, true, previousHash)
115+
} else {
116+
return (current, true, previousHash)
117+
}
118+
} else {
119+
return (.fetching, true, nil)
99120
}
100-
} else {
101-
return (.fetching, true, nil)
102-
}
103121
}
104122
}
105123
|> mapToSignal { result, loadRemote, previousHash in
@@ -111,10 +129,8 @@ public func cachedStickerPack(postbox: Postbox, network: Network, reference: Sti
111129
}
112130
return postbox.transaction { transaction -> CachedStickerPackResult in
113131
if let result = result {
114-
cacheStickerPack(transaction: transaction, info: result.0, items: result.1)
115-
132+
cacheStickerPack(transaction: transaction, info: result.0, items: result.1, reference: reference)
116133
let currentInfo = transaction.getItemCollectionInfo(collectionId: result.0.id) as? StickerPackCollectionInfo
117-
118134
return .result(result.0, result.1, currentInfo != nil)
119135
} else {
120136
return .none
@@ -134,30 +150,42 @@ public func cachedStickerPack(postbox: Postbox, network: Network, reference: Sti
134150
func cachedStickerPack(transaction: Transaction, reference: StickerPackReference) -> (StickerPackCollectionInfo, [ItemCollectionItem], Bool)? {
135151
let namespace = Namespaces.ItemCollection.CloudStickerPacks
136152
switch reference {
137-
case let .id(id, _):
138-
if let currentInfo = transaction.getItemCollectionInfo(collectionId: ItemCollectionId(namespace: namespace, id: id)) as? StickerPackCollectionInfo {
139-
let items = transaction.getItemCollectionItems(collectionId: ItemCollectionId(namespace: namespace, id: id))
140-
if !items.isEmpty {
141-
return (currentInfo, items, true)
153+
case let .id(id, _):
154+
if let currentInfo = transaction.getItemCollectionInfo(collectionId: ItemCollectionId(namespace: namespace, id: id)) as? StickerPackCollectionInfo {
155+
let items = transaction.getItemCollectionItems(collectionId: ItemCollectionId(namespace: namespace, id: id))
156+
if !items.isEmpty {
157+
return (currentInfo, items, true)
158+
}
142159
}
143-
}
144-
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id)))) as? CachedStickerPack, let info = cached.info {
145-
return (info, cached.items, false)
146-
}
147-
case let .name(shortName):
148-
for info in transaction.getItemCollectionsInfos(namespace: namespace) {
149-
if let info = info.1 as? StickerPackCollectionInfo {
150-
if info.shortName == shortName {
151-
let items = transaction.getItemCollectionItems(collectionId: info.id)
152-
if !items.isEmpty {
153-
return (info, items, true)
160+
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id)))) as? CachedStickerPack, let info = cached.info {
161+
return (info, cached.items, false)
162+
}
163+
case let .name(shortName):
164+
for info in transaction.getItemCollectionsInfos(namespace: namespace) {
165+
if let info = info.1 as? StickerPackCollectionInfo {
166+
if info.shortName == shortName {
167+
let items = transaction.getItemCollectionItems(collectionId: info.id)
168+
if !items.isEmpty {
169+
return (info, items, true)
170+
}
154171
}
155172
}
156173
}
157-
}
158-
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(shortName: shortName))) as? CachedStickerPack, let info = cached.info {
159-
return (info, cached.items, false)
160-
}
174+
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(shortName: shortName))) as? CachedStickerPack, let info = cached.info {
175+
return (info, cached.items, false)
176+
}
177+
case .animatedEmoji:
178+
let namespace = Namespaces.ItemCollection.CloudAnimatedEmoji
179+
let id: ItemCollectionId.Id = 0
180+
if let currentInfo = transaction.getItemCollectionInfo(collectionId: ItemCollectionId(namespace: namespace, id: id)) as? StickerPackCollectionInfo {
181+
let items = transaction.getItemCollectionItems(collectionId: ItemCollectionId(namespace: namespace, id: id))
182+
if !items.isEmpty {
183+
return (currentInfo, items, true)
184+
}
185+
}
186+
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id)))) as? CachedStickerPack, let info = cached.info {
187+
return (info, cached.items, false)
188+
}
161189
}
162190
return nil
163191
}

‎submodules/TelegramCore/TelegramCore/LoadedStickerPack.swift‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ extension StickerPackReference {
2020
return .inputStickerSetID(id: id, accessHash: accessHash)
2121
case let .name(name):
2222
return .inputStickerSetShortName(shortName: name)
23+
case .animatedEmoji:
24+
return .inputStickerSetAnimatedEmoji
2325
}
2426
}
2527
}

‎submodules/TelegramCore/TelegramCore/ManagedSecretChatOutgoingOperations.swift‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,8 @@ private func decryptedAttributes46(_ attributes: [TelegramMediaFileAttribute], t
504504
if let (info, _, _) = cachedStickerPack(transaction: transaction, reference: packReference) {
505505
stickerSet = .inputStickerSetShortName(shortName: info.shortName)
506506
}
507+
default:
508+
stickerSet = .inputStickerSetEmpty
507509
}
508510
}
509511
result.append(.documentAttributeSticker(alt: displayText, stickerset: stickerSet))
@@ -553,6 +555,8 @@ private func decryptedAttributes73(_ attributes: [TelegramMediaFileAttribute], t
553555
if let (info, _, _) = cachedStickerPack(transaction: transaction, reference: packReference) {
554556
stickerSet = .inputStickerSetShortName(shortName: info.shortName)
555557
}
558+
default:
559+
stickerSet = .inputStickerSetEmpty
556560
}
557561
}
558562
result.append(.documentAttributeSticker(alt: displayText, stickerset: stickerSet))
@@ -600,12 +604,14 @@ private func decryptedAttributes101(_ attributes: [TelegramMediaFileAttribute],
600604
var stickerSet: SecretApi101.InputStickerSet = .inputStickerSetEmpty
601605
if let packReference = packReference {
602606
switch packReference {
603-
case let .name(name):
604-
stickerSet = .inputStickerSetShortName(shortName: name)
605-
case .id:
606-
if let (info, _, _) = cachedStickerPack(transaction: transaction, reference: packReference) {
607-
stickerSet = .inputStickerSetShortName(shortName: info.shortName)
608-
}
607+
case let .name(name):
608+
stickerSet = .inputStickerSetShortName(shortName: name)
609+
case .id:
610+
if let (info, _, _) = cachedStickerPack(transaction: transaction, reference: packReference) {
611+
stickerSet = .inputStickerSetShortName(shortName: info.shortName)
612+
}
613+
default:
614+
stickerSet = .inputStickerSetEmpty
609615
}
610616
}
611617
result.append(.documentAttributeSticker(alt: displayText, stickerset: stickerSet))

‎submodules/TelegramCore/TelegramCore/Namespaces.swift‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public struct Namespaces {
4242
public static let CloudStickerPacks: Int32 = 0
4343
public static let CloudMaskPacks: Int32 = 1
4444
public static let EmojiKeywords: Int32 = 2
45+
public static let CloudAnimatedEmoji: Int32 = 3
4546
}
4647

4748
public struct OrderedItemList {

‎submodules/TelegramCore/TelegramCore/PendingMessageUploadedContent.swift‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ func inputDocumentAttributesFromFileAttributes(_ fileAttributes: [TelegramMediaF
417417
stickerSet = .inputStickerSetID(id: id, accessHash: accessHash)
418418
case let .name(name):
419419
stickerSet = .inputStickerSetShortName(shortName: name)
420+
default:
421+
stickerSet = .inputStickerSetEmpty
420422
}
421423
}
422424
var inputMaskCoords: Api.MaskCoords?

‎submodules/TelegramCore/TelegramCore/StickerSetInstallation.swift‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public func requestStickerSet(postbox: Postbox, network: Network, reference: Sti
3939
case let .id(id, accessHash):
4040
collectionId = ItemCollectionId(namespace: Namespaces.ItemCollection.CloudStickerPacks, id: id)
4141
input = .inputStickerSetID(id: id, accessHash: accessHash)
42+
case .animatedEmoji:
43+
collectionId = nil
44+
input = .inputStickerSetAnimatedEmoji
4245
}
4346

4447
let localSignal: (ItemCollectionId) -> Signal<(ItemCollectionInfo, [ItemCollectionItem])?, NoError> = { collectionId in

‎submodules/TelegramCore/TelegramCore/SynchronizeSavedStickersOperation.swift‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ public func addSavedSticker(postbox: Postbox, network: Network, file: TelegramMe
128128
if !found {
129129
fetchReference = packReference
130130
}
131+
case .animatedEmoji:
132+
break
131133
}
132134
if let fetchReference = fetchReference {
133135
return network.request(Api.functions.messages.getStickerSet(stickerset: fetchReference.apiInputStickerSet))

‎submodules/TelegramCore/TelegramCore/TelegramMediaFile.swift‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ private let typeHasLinkedStickers: Int32 = 6
2020
public enum StickerPackReference: PostboxCoding, Hashable, Equatable {
2121
case id(id: Int64, accessHash: Int64)
2222
case name(String)
23+
case animatedEmoji
2324

2425
public init(decoder: PostboxDecoder) {
2526
switch decoder.decodeInt32ForKey("r", orElse: 0) {
2627
case 0:
2728
self = .id(id: decoder.decodeInt64ForKey("i", orElse: 0), accessHash: decoder.decodeInt64ForKey("h", orElse: 0))
2829
case 1:
2930
self = .name(decoder.decodeStringForKey("n", orElse: ""))
31+
case 2:
32+
self = .animatedEmoji
3033
default:
3134
self = .name("")
3235
assertionFailure()
@@ -42,6 +45,8 @@ public enum StickerPackReference: PostboxCoding, Hashable, Equatable {
4245
case let .name(name):
4346
encoder.encodeInt32(1, forKey: "r")
4447
encoder.encodeString(name, forKey: "n")
48+
case .animatedEmoji:
49+
encoder.encodeInt32(2, forKey: "r")
4550
}
4651
}
4752

@@ -59,6 +64,12 @@ public enum StickerPackReference: PostboxCoding, Hashable, Equatable {
5964
} else {
6065
return false
6166
}
67+
case .animatedEmoji:
68+
if case .animatedEmoji = rhs {
69+
return true
70+
} else {
71+
return false
72+
}
6273
}
6374
}
6475
}
@@ -510,6 +521,8 @@ extension StickerPackReference {
510521
self = .id(id: id, accessHash: accessHash)
511522
case let .inputStickerSetShortName(shortName):
512523
self = .name(shortName)
524+
case .inputStickerSetAnimatedEmoji:
525+
self = .animatedEmoji
513526
}
514527
}
515528
}

0 commit comments

Comments
 (0)