From b686512d72cd000ce769b424020bd26379403efe Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 24 Jun 2023 19:25:53 +0300 Subject: same check for animated stickers --- protocols/Telegram/src/utils.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'protocols') diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp index 250a3561d2..d646e96123 100644 --- a/protocols/Telegram/src/utils.cpp +++ b/protocols/Telegram/src/utils.cpp @@ -339,6 +339,17 @@ static const TD::photoSize* GetBiggestPhoto(const TD::photo *pPhoto) return nullptr; } +static bool checkStickerType(uint32_t ID) +{ + switch (ID) { + case TD::stickerTypeRegular::ID: + case TD::stickerFullTypeRegular::ID: + return true; + default: + return false; + } +} + static const char *getFormattedText(TD::object_ptr &pText) { if (pText->get_id() == TD::formattedText::ID) @@ -416,8 +427,10 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg case TD::messageAnimatedEmoji::ID: if (m_bSmileyAdd) { auto *pSticker = ((TD::messageAnimatedEmoji *)pBody)->animated_emoji_->sticker_.get(); - if (pSticker->full_type_->get_id() != TD::stickerTypeRegular::ID) + if (!checkStickerType(pSticker->full_type_->get_id())) { + debugLogA("You received a sticker of unsupported type %d, ignored", pSticker->full_type_->get_id()); break; + } const char *pwszFileExt; switch (pSticker->thumbnail_->format_->get_id()) { @@ -437,12 +450,7 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg case TD::messageSticker::ID: { auto *pSticker = ((TD::messageSticker *)pBody)->sticker_.get(); - switch(pSticker->full_type_->get_id()) { - case TD::stickerTypeRegular::ID: - case TD::stickerFullTypeRegular::ID: - break; - - default: + if (!checkStickerType(pSticker->full_type_->get_id())) { debugLogA("You received a sticker of unsupported type %d, ignored", pSticker->full_type_->get_id()); break; } -- cgit v1.2.3