Update Ghostgram features

This commit is contained in:
ichmagmaus 812
2026-03-07 18:15:32 +01:00
parent 1a3303b059
commit 24a7ec39d9
902 changed files with 148302 additions and 62355 deletions
@@ -143,19 +143,21 @@ private enum SynchronizeInstalledStickerPacksError {
}
private func fetchStickerPack(network: Network, info: StickerPackCollectionInfo) -> Signal<(StickerPackCollectionInfo, [ItemCollectionItem]), NoError> {
return network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash), hash: 0))
return network.request(Api.functions.messages.getStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)), hash: 0))
|> map { result -> (StickerPackCollectionInfo, [ItemCollectionItem]) in
var items: [ItemCollectionItem] = []
var updatedInfo = info
switch result {
case .stickerSetNotModified:
break
case let .stickerSet(stickerSet, packs, keywords, documents):
case let .stickerSet(stickerSetData):
let (stickerSet, packs, keywords, documents) = (stickerSetData.set, stickerSetData.packs, stickerSetData.keywords, stickerSetData.documents)
updatedInfo = StickerPackCollectionInfo(apiSet: stickerSet, namespace: info.id.namespace)
var indexKeysByFile: [MediaId: [MemoryBuffer]] = [:]
for pack in packs {
switch pack {
case let .stickerPack(text, fileIds):
case let .stickerPack(stickerPackData):
let (text, fileIds) = (stickerPackData.emoticon, stickerPackData.documents)
let key = ValueBoxKey(text).toMemoryBuffer()
for fileId in fileIds {
let mediaId = MediaId(namespace: Namespaces.Media.CloudFile, id: fileId)
@@ -170,7 +172,8 @@ private func fetchStickerPack(network: Network, info: StickerPackCollectionInfo)
}
for keyword in keywords {
switch keyword {
case let .stickerKeyword(documentId, texts):
case let .stickerKeyword(stickerKeywordData):
let (documentId, texts) = (stickerKeywordData.documentId, stickerKeywordData.keyword)
for text in texts {
let key = ValueBoxKey(text).toMemoryBuffer()
let mediaId = MediaId(namespace: Namespaces.Media.CloudFile, id: documentId)
@@ -228,22 +231,27 @@ private func resolveStickerPacks(network: Network, remoteInfos: [ItemCollectionI
private func installRemoteStickerPacks(network: Network, infos: [StickerPackCollectionInfo]) -> Signal<Set<ItemCollectionId>, NoError> {
var signals: [Signal<Set<ItemCollectionId>, NoError>] = []
for info in infos {
let install = network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash), archived: .boolFalse))
let install = network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)), archived: .boolFalse))
|> map { result -> Set<ItemCollectionId> in
switch result {
case .stickerSetInstallResultSuccess:
return Set()
case let .stickerSetInstallResultArchive(archivedSets):
case let .stickerSetInstallResultArchive(stickerSetInstallResultArchiveData):
let archivedSets = stickerSetInstallResultArchiveData.sets
var archivedIds = Set<ItemCollectionId>()
for archivedSet in archivedSets {
switch archivedSet {
case let .stickerSetCovered(set, _):
case let .stickerSetCovered(stickerSetCoveredData):
let set = stickerSetCoveredData.set
archivedIds.insert(StickerPackCollectionInfo(apiSet: set, namespace: info.id.namespace).id)
case let .stickerSetMultiCovered(set, _):
case let .stickerSetMultiCovered(stickerSetMultiCoveredData):
let set = stickerSetMultiCoveredData.set
archivedIds.insert(StickerPackCollectionInfo(apiSet: set, namespace: info.id.namespace).id)
case let .stickerSetFullCovered(set, _, _, _):
case let .stickerSetFullCovered(stickerSetFullCoveredData):
let set = stickerSetFullCoveredData.set
archivedIds.insert(StickerPackCollectionInfo(apiSet: set, namespace: info.id.namespace).id)
case let .stickerSetNoCovered(set):
case let .stickerSetNoCovered(stickerSetNoCoveredData):
let set = stickerSetNoCoveredData.set
archivedIds.insert(StickerPackCollectionInfo(apiSet: set, namespace: info.id.namespace).id)
}
}
@@ -268,7 +276,7 @@ private func installRemoteStickerPacks(network: Network, infos: [StickerPackColl
private func removeRemoteStickerPacks(network: Network, infos: [StickerPackCollectionInfo]) -> Signal<Void, NoError> {
if infos.count > 0 {
if infos.count > 1 {
return network.request(Api.functions.messages.toggleStickerSets(flags: 1 << 0, stickersets: infos.map { .inputStickerSetID(id: $0.id.id, accessHash: $0.accessHash) }))
return network.request(Api.functions.messages.toggleStickerSets(flags: 1 << 0, stickersets: infos.map { .inputStickerSetID(.init(id: $0.id.id, accessHash: $0.accessHash)) }))
|> mapToSignal { _ -> Signal<Void, MTRpcError> in
return .single(Void())
}
@@ -276,7 +284,7 @@ private func removeRemoteStickerPacks(network: Network, infos: [StickerPackColle
return .single(Void())
}
} else if let info = infos.first {
return network.request(Api.functions.messages.uninstallStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash)))
return network.request(Api.functions.messages.uninstallStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash))))
|> mapToSignal { _ -> Signal<Void, MTRpcError> in
return .single(Void())
}
@@ -291,7 +299,7 @@ private func removeRemoteStickerPacks(network: Network, infos: [StickerPackColle
private func archiveRemoteStickerPacks(network: Network, infos: [StickerPackCollectionInfo]) -> Signal<Void, NoError> {
if infos.count > 0 {
if infos.count > 1 {
return network.request(Api.functions.messages.toggleStickerSets(flags: 1 << 1, stickersets: infos.map { .inputStickerSetID(id: $0.id.id, accessHash: $0.accessHash) }))
return network.request(Api.functions.messages.toggleStickerSets(flags: 1 << 1, stickersets: infos.map { .inputStickerSetID(.init(id: $0.id.id, accessHash: $0.accessHash)) }))
|> mapToSignal { _ -> Signal<Void, MTRpcError> in
return .single(Void())
}
@@ -299,7 +307,7 @@ private func archiveRemoteStickerPacks(network: Network, infos: [StickerPackColl
return .single(Void())
}
} else if let info = infos.first {
return network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(id: info.id.id, accessHash: info.accessHash), archived: .boolTrue))
return network.request(Api.functions.messages.installStickerSet(stickerset: .inputStickerSetID(.init(id: info.id.id, accessHash: info.accessHash)), archived: .boolTrue))
|> mapToSignal { _ -> Signal<Void, MTRpcError> in
return .single(Void())
}
@@ -501,7 +509,8 @@ private func continueSynchronizeInstalledStickerPacks(transaction: Transaction,
var remoteCollectionInfos: [StickerPackCollectionInfo] = []
switch result {
case let .allStickers(_, sets):
case let .allStickers(allStickersData):
let sets = allStickersData.sets
for apiSet in sets {
let info = StickerPackCollectionInfo(apiSet: apiSet, namespace: collectionNamespace)
remoteCollectionInfos.append(info)