Ignore document and chat photo minithumbnails by bots.

This commit is contained in:
levlam 2021-05-27 21:15:30 +03:00
parent 5832a59ee5
commit d7c739dc70
8 changed files with 50 additions and 31 deletions

View File

@ -18,10 +18,9 @@
#include "td/telegram/logevent/LogEvent.h"
#include "td/telegram/misc.h"
#include "td/telegram/SecretChatActor.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
@ -337,7 +336,9 @@ void AnimationsManager::create_animation(FileId file_id, string minithumbnail, P
a->mime_type = std::move(mime_type);
a->duration = max(duration, 0);
a->dimensions = dimensions;
a->minithumbnail = std::move(minithumbnail);
if (!td_->auth_manager_->is_bot()) {
a->minithumbnail = std::move(minithumbnail);
}
a->thumbnail = std::move(thumbnail);
a->animated_thumbnail = std::move(animated_thumbnail);
a->has_stickers = has_stickers;

View File

@ -6,10 +6,10 @@
//
#include "td/telegram/AudiosManager.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/Td.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
@ -180,7 +180,9 @@ void AudiosManager::create_audio(FileId file_id, string minithumbnail, PhotoSize
a->duration = max(duration, 0);
a->title = std::move(title);
a->performer = std::move(performer);
a->minithumbnail = std::move(minithumbnail);
if (!td_->auth_manager_->is_bot()) {
a->minithumbnail = std::move(minithumbnail);
}
a->thumbnail = std::move(thumbnail);
on_get_audio(std::move(a), replace);
}

View File

@ -10839,8 +10839,11 @@ void ContactsManager::on_update_user_photo(User *u, UserId user_id,
void ContactsManager::do_update_user_photo(User *u, UserId user_id,
tl_object_ptr<telegram_api::UserProfilePhoto> &&photo, const char *source) {
do_update_user_photo(
u, user_id, get_profile_photo(td_->file_manager_.get(), user_id, u->access_hash, std::move(photo)), true, source);
ProfilePhoto new_photo = get_profile_photo(td_->file_manager_.get(), user_id, u->access_hash, std::move(photo));
if (td_->auth_manager_->is_bot()) {
new_photo.minithumbnail.clear();
}
do_update_user_photo(u, user_id, std::move(new_photo), true, source);
}
void ContactsManager::do_update_user_photo(User *u, UserId user_id, ProfilePhoto new_photo, bool invalidate_photo_cache,
@ -12870,6 +12873,9 @@ void ContactsManager::on_update_chat_photo(Chat *c, ChatId chat_id,
tl_object_ptr<telegram_api::ChatPhoto> &&chat_photo_ptr) {
DialogPhoto new_chat_photo =
get_dialog_photo(td_->file_manager_.get(), DialogId(chat_id), 0, std::move(chat_photo_ptr));
if (td_->auth_manager_->is_bot()) {
new_chat_photo.minithumbnail.clear();
}
if (new_chat_photo != c->photo) {
c->photo = new_chat_photo;
@ -13008,6 +13014,9 @@ void ContactsManager::on_update_channel_photo(Channel *c, ChannelId channel_id,
tl_object_ptr<telegram_api::ChatPhoto> &&chat_photo_ptr) {
DialogPhoto new_chat_photo =
get_dialog_photo(td_->file_manager_.get(), DialogId(channel_id), c->access_hash, std::move(chat_photo_ptr));
if (td_->auth_manager_->is_bot()) {
new_chat_photo.minithumbnail.clear();
}
if (new_chat_photo != c->photo) {
c->photo = new_chat_photo;

View File

@ -17,16 +17,15 @@
#include "td/telegram/misc.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/Photo.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/StickersManager.h"
#include "td/telegram/Td.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/VideoNotesManager.h"
#include "td/telegram/VideosManager.h"
#include "td/telegram/VoiceNotesManager.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/common.h"
#include "td/utils/format.h"
#include "td/utils/HttpUrl.h"
@ -513,7 +512,9 @@ void DocumentsManager::create_document(FileId file_id, string minithumbnail, Pho
d->file_id = file_id;
d->file_name = std::move(file_name);
d->mime_type = std::move(mime_type);
d->minithumbnail = std::move(minithumbnail);
if (!td_->auth_manager_->is_bot()) {
d->minithumbnail = std::move(minithumbnail);
}
d->thumbnail = std::move(thumbnail);
on_get_document(std::move(d), replace);
}

View File

@ -6,10 +6,6 @@
//
#include "td/telegram/StickersManager.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/AccessRights.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/ConfigManager.h"
@ -29,10 +25,13 @@
#include "td/telegram/misc.h"
#include "td/telegram/net/DcId.h"
#include "td/telegram/net/MtprotoHeader.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/StickerSetId.hpp"
#include "td/telegram/StickersManager.hpp"
#include "td/telegram/Td.h"
#include "td/telegram/TdDb.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/actor/MultiPromise.h"
#include "td/actor/PromiseFuture.h"
@ -2253,7 +2252,9 @@ void StickersManager::create_sticker(FileId file_id, string minithumbnail, Photo
auto s = make_unique<Sticker>();
s->file_id = file_id;
s->dimensions = dimensions;
s->minithumbnail = std::move(minithumbnail);
if (!td_->auth_manager_->is_bot()) {
s->minithumbnail = std::move(minithumbnail);
}
add_sticker_thumbnail(s.get(), thumbnail);
if (sticker != nullptr) {
s->set_id = on_get_input_sticker_set(file_id, std::move(sticker->stickerset_), load_data_multipromise_ptr);
@ -2461,7 +2462,9 @@ StickerSetId StickersManager::on_get_sticker_set(tl_object_ptr<telegram_api::sti
s->is_inited = true;
s->title = std::move(set->title_);
s->short_name = std::move(set->short_name_);
s->minithumbnail = std::move(minithumbnail);
if (!td_->auth_manager_->is_bot()) {
s->minithumbnail = std::move(minithumbnail);
}
s->thumbnail = std::move(thumbnail);
s->is_thumbnail_reloaded = true;
s->are_legacy_sticker_thumbnails_reloaded = true;

View File

@ -6,13 +6,13 @@
//
#include "td/telegram/VideoNotesManager.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/SecretChatActor.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/Td.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
@ -158,7 +158,9 @@ void VideoNotesManager::create_video_note(FileId file_id, string minithumbnail,
} else {
LOG(INFO) << "Receive wrong video note dimensions " << dimensions;
}
v->minithumbnail = std::move(minithumbnail);
if (!td_->auth_manager_->is_bot()) {
v->minithumbnail = std::move(minithumbnail);
}
v->thumbnail = std::move(thumbnail);
on_get_video_note(std::move(v), replace);
}

View File

@ -6,13 +6,13 @@
//
#include "td/telegram/VideosManager.h"
#include "td/telegram/AuthManager.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/Td.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Td.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/Status.h"
@ -203,7 +203,9 @@ void VideosManager::create_video(FileId file_id, string minithumbnail, PhotoSize
v->mime_type = std::move(mime_type);
v->duration = max(duration, 0);
v->dimensions = dimensions;
v->minithumbnail = std::move(minithumbnail);
if (!td_->auth_manager_->is_bot()) {
v->minithumbnail = std::move(minithumbnail);
}
v->thumbnail = std::move(thumbnail);
v->animated_thumbnail = std::move(animated_thumbnail);
v->supports_streaming = supports_streaming;

View File

@ -6,13 +6,12 @@
//
#include "td/telegram/VoiceNotesManager.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/secret_api.h"
#include "td/telegram/Td.h"
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/files/FileManager.h"
#include "td/telegram/Td.h"
#include "td/utils/buffer.h"
#include "td/utils/logging.h"
#include "td/utils/misc.h"