Group boosts

This commit is contained in:
Ilya Laktyushin
2024-02-01 12:29:07 +04:00
parent 2716a936bf
commit 1b2b7dc403
120 changed files with 5295 additions and 887 deletions

View File

@@ -40,3 +40,41 @@ func _internal_updateGroupSpecificStickerset(postbox: Postbox, network: Network,
return .complete()
}
}
public enum UpdateGroupSpecificEmojisetError {
case generic
}
func _internal_updateGroupSpecificEmojiset(postbox: Postbox, network: Network, peerId: PeerId, info: StickerPackCollectionInfo?) -> Signal<Void, UpdateGroupSpecificEmojisetError> {
return postbox.loadedPeerWithId(peerId)
|> castError(UpdateGroupSpecificEmojisetError.self)
|> mapToSignal { peer -> Signal<Void, UpdateGroupSpecificEmojisetError> in
let inputStickerset: Api.InputStickerSet
if let info = info {
inputStickerset = Api.InputStickerSet.inputStickerSetShortName(shortName: info.shortName)
} else {
inputStickerset = Api.InputStickerSet.inputStickerSetEmpty
}
if let inputChannel = apiInputChannel(peer) {
return network.request(Api.functions.channels.setEmojiStickers(channel: inputChannel, stickerset: inputStickerset))
|> mapError { _ -> UpdateGroupSpecificEmojisetError in
return .generic
}
|> mapToSignal { value -> Signal<Void, UpdateGroupSpecificEmojisetError> in
switch value {
case .boolTrue:
return postbox.transaction { transaction -> Void in
return transaction.updatePeerCachedData(peerIds: [peerId], update: { _, current -> CachedPeerData? in
return (current as? CachedChannelData)?.withUpdatedEmojiPack(info)
})
}
|> castError(UpdateGroupSpecificEmojisetError.self)
default:
return .complete()
}
}
}
return .complete()
}
}