summaryrefslogtreecommitdiff
path: root/protocols/Telegram/src/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Telegram/src/utils.cpp')
-rw-r--r--protocols/Telegram/src/utils.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/protocols/Telegram/src/utils.cpp b/protocols/Telegram/src/utils.cpp
index 65d9292d68..768c7972f3 100644
--- a/protocols/Telegram/src/utils.cpp
+++ b/protocols/Telegram/src/utils.cpp
@@ -508,7 +508,7 @@ CMStringA CTelegramProto::GetMessagePreview(const TD::file *pFile)
return T2Utf(pRequest->m_destPath + L"\\" + pRequest->m_fileName).get();
}
-CMStringA CTelegramProto::GetMessageSticker(const TD::file *pFile, const char *pwszExtension)
+CMStringA CTelegramProto::GetMessageSticker(const TD::file *pFile, const TD::ThumbnailFormat *pFormat)
{
auto *pFileId = pFile->remote_->unique_id_.c_str();
@@ -517,7 +517,18 @@ CMStringA CTelegramProto::GetMessageSticker(const TD::file *pFile, const char *p
pRequest->m_destPath = GetAvatarPath() + L"\\Stickers";
CreateDirectoryW(pRequest->m_destPath, 0);
- pRequest->m_fileName.Format(L"STK{%S}.%S", pFileId, pwszExtension);
+ const char *pszFileExt;
+ switch (pFormat->get_id()) {
+ case TD::thumbnailFormatGif::ID: pszFileExt = "gif"; break;
+ case TD::thumbnailFormatPng::ID: pszFileExt = "png"; break;
+ case TD::thumbnailFormatTgs::ID: pszFileExt = "tga"; break;
+ case TD::thumbnailFormatJpeg::ID: pszFileExt = "jpg"; break;
+ case TD::thumbnailFormatWebm::ID: pszFileExt = "webm"; break;
+ case TD::thumbnailFormatWebp::ID: pszFileExt = "webp"; break;
+ default:pszFileExt = "jpeg"; break;
+ }
+
+ pRequest->m_fileName.Format(L"STK{%S}.%S", pFileId, pszFileExt);
{
mir_cslock lck(m_csFiles);
m_arFiles.insert(pRequest);
@@ -713,18 +724,7 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg
break;
}
- const char *pwszFileExt;
- switch (pSticker->thumbnail_->format_->get_id()) {
- case TD::thumbnailFormatGif::ID: pwszFileExt = "gif"; break;
- case TD::thumbnailFormatPng::ID: pwszFileExt = "png"; break;
- case TD::thumbnailFormatTgs::ID: pwszFileExt = "tga"; break;
- case TD::thumbnailFormatJpeg::ID: pwszFileExt = "jpg"; break;
- case TD::thumbnailFormatWebm::ID: pwszFileExt = "webm"; break;
- case TD::thumbnailFormatWebp::ID: pwszFileExt = "webp"; break;
- default:pwszFileExt = "jpeg"; break;
- }
-
- ret = GetMessageSticker(pSticker->thumbnail_->file_.get(), pwszFileExt);
+ ret = GetMessageSticker(pSticker->thumbnail_->file_.get(), pSticker->thumbnail_->format_.get());
break;
}
}
@@ -742,15 +742,7 @@ CMStringA CTelegramProto::GetMessageText(TG_USER *pUser, const TD::message *pMsg
if (m_bSmileyAdd) {
if (pSticker->thumbnail_.get()) {
- const char *pwszFileExt;
- switch (pSticker->format_->get_id()) {
- case TD::stickerFormatTgs::ID: pwszFileExt = "tga"; break;
- case TD::stickerFormatWebm::ID: pwszFileExt = "webm"; break;
- case TD::stickerFormatWebp::ID: pwszFileExt = "webp"; break;
- default:
- pwszFileExt = "jpeg"; break;
- }
- ret = GetMessageSticker(pSticker->thumbnail_->file_.get(), pwszFileExt);
+ ret = GetMessageSticker(pSticker->thumbnail_->file_.get(), pSticker->thumbnail_->format_.get());
}
else {
debugLogA("Strange sticker without preview");