Add get_sticker_type function.
This commit is contained in:
parent
ac4e76edf1
commit
7618c9aa64
@ -10,6 +10,23 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
StickerFormat get_sticker_format(const td_api::object_ptr<td_api::StickerType> &type) {
|
||||||
|
CHECK(type != nullptr);
|
||||||
|
switch (type->get_id()) {
|
||||||
|
case td_api::stickerTypeStatic::ID:
|
||||||
|
return StickerFormat::Webp;
|
||||||
|
case td_api::stickerTypeAnimated::ID:
|
||||||
|
return StickerFormat::Tgs;
|
||||||
|
case td_api::stickerTypeVideo::ID:
|
||||||
|
return StickerFormat::Webm;
|
||||||
|
case td_api::stickerTypeMask::ID:
|
||||||
|
return StickerFormat::Webp;
|
||||||
|
default:
|
||||||
|
UNREACHABLE();
|
||||||
|
return StickerFormat::Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StickerFormat get_sticker_format_by_mime_type(Slice mime_type) {
|
StickerFormat get_sticker_format_by_mime_type(Slice mime_type) {
|
||||||
if (mime_type == "application/x-tgsticker") {
|
if (mime_type == "application/x-tgsticker") {
|
||||||
return StickerFormat::Tgs;
|
return StickerFormat::Tgs;
|
||||||
|
@ -18,6 +18,8 @@ namespace td {
|
|||||||
// update store_sticker/store_sticker_set when this type changes
|
// update store_sticker/store_sticker_set when this type changes
|
||||||
enum class StickerFormat : int32 { Unknown, Webp, Tgs, Webm };
|
enum class StickerFormat : int32 { Unknown, Webp, Tgs, Webm };
|
||||||
|
|
||||||
|
StickerFormat get_sticker_format(const td_api::object_ptr<td_api::StickerType> &type);
|
||||||
|
|
||||||
StickerFormat get_sticker_format_by_mime_type(Slice mime_type);
|
StickerFormat get_sticker_format_by_mime_type(Slice mime_type);
|
||||||
|
|
||||||
StickerFormat get_sticker_format_by_extension(Slice extension);
|
StickerFormat get_sticker_format_by_extension(Slice extension);
|
||||||
|
@ -5794,19 +5794,7 @@ Result<std::tuple<FileId, bool, bool, StickerFormat>> StickersManager::prepare_i
|
|||||||
return Status::Error(400, "Sticker type must be non-empty");
|
return Status::Error(400, "Sticker type must be non-empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (sticker->type_->get_id()) {
|
return prepare_input_file(sticker->sticker_, get_sticker_format(sticker->type_), false);
|
||||||
case td_api::stickerTypeStatic::ID:
|
|
||||||
return prepare_input_file(sticker->sticker_, StickerFormat::Webp, false);
|
|
||||||
case td_api::stickerTypeAnimated::ID:
|
|
||||||
return prepare_input_file(sticker->sticker_, StickerFormat::Tgs, false);
|
|
||||||
case td_api::stickerTypeVideo::ID:
|
|
||||||
return prepare_input_file(sticker->sticker_, StickerFormat::Webm, false);
|
|
||||||
case td_api::stickerTypeMask::ID:
|
|
||||||
return prepare_input_file(sticker->sticker_, StickerFormat::Webp, false);
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<std::tuple<FileId, bool, bool, StickerFormat>> StickersManager::prepare_input_file(
|
Result<std::tuple<FileId, bool, bool, StickerFormat>> StickersManager::prepare_input_file(
|
||||||
|
Loading…
Reference in New Issue
Block a user