Reload ChatFull with outdated photo.

This commit is contained in:
levlam 2022-06-20 18:40:13 +03:00
parent f3792b15a3
commit 54fea1a8c5
2 changed files with 13 additions and 6 deletions

View File

@ -14824,7 +14824,8 @@ ContactsManager::ChatFull *ContactsManager::add_chat_full(ChatId chat_id) {
return chat_full_ptr.get(); return chat_full_ptr.get();
} }
bool ContactsManager::is_chat_full_outdated(const ChatFull *chat_full, const Chat *c, ChatId chat_id) { bool ContactsManager::is_chat_full_outdated(const ChatFull *chat_full, const Chat *c, ChatId chat_id,
bool only_participants) const {
CHECK(c != nullptr); CHECK(c != nullptr);
CHECK(chat_full != nullptr); CHECK(chat_full != nullptr);
if (!c->is_active && chat_full->version == -1) { if (!c->is_active && chat_full->version == -1) {
@ -14837,11 +14838,17 @@ bool ContactsManager::is_chat_full_outdated(const ChatFull *chat_full, const Cha
return true; return true;
} }
if (c->is_active && c->status.can_manage_invite_links() && !chat_full->invite_link.is_valid()) { if (!only_participants && c->is_active && c->status.can_manage_invite_links() && !chat_full->invite_link.is_valid()) {
LOG(INFO) << "Have outdated invite link in " << chat_id; LOG(INFO) << "Have outdated invite link in " << chat_id;
return true; return true;
} }
if (!only_participants &&
!is_same_dialog_photo(td_->file_manager_.get(), DialogId(chat_id), chat_full->photo, c->photo)) {
LOG(INFO) << "Have outdated chat photo in " << chat_id;
return true;
}
LOG(DEBUG) << "Full " << chat_id << " is up-to-date with version " << chat_full->version; LOG(DEBUG) << "Full " << chat_id << " is up-to-date with version " << chat_full->version;
return false; return false;
} }
@ -14858,7 +14865,7 @@ void ContactsManager::load_chat_full(ChatId chat_id, bool force, Promise<Unit> &
return send_get_chat_full_query(chat_id, std::move(promise), source); return send_get_chat_full_query(chat_id, std::move(promise), source);
} }
if (is_chat_full_outdated(chat_full, c, chat_id)) { if (is_chat_full_outdated(chat_full, c, chat_id, false)) {
LOG(INFO) << "Have outdated full " << chat_id; LOG(INFO) << "Have outdated full " << chat_id;
if (td_->auth_manager_->is_bot() && !force) { if (td_->auth_manager_->is_bot() && !force) {
return send_get_chat_full_query(chat_id, std::move(promise), source); return send_get_chat_full_query(chat_id, std::move(promise), source);
@ -15680,7 +15687,7 @@ void ContactsManager::get_chat_participant(ChatId chat_id, UserId user_id, Promi
} }
auto chat_full = get_chat_full_force(chat_id, "get_chat_participant"); auto chat_full = get_chat_full_force(chat_id, "get_chat_participant");
if (chat_full == nullptr || (td_->auth_manager_->is_bot() && is_chat_full_outdated(chat_full, c, chat_id))) { if (chat_full == nullptr || (td_->auth_manager_->is_bot() && is_chat_full_outdated(chat_full, c, chat_id, true))) {
auto query_promise = PromiseCreator::lambda( auto query_promise = PromiseCreator::lambda(
[actor_id = actor_id(this), chat_id, user_id, promise = std::move(promise)](Result<Unit> &&result) mutable { [actor_id = actor_id(this), chat_id, user_id, promise = std::move(promise)](Result<Unit> &&result) mutable {
TRY_STATUS_PROMISE(promise, std::move(result)); TRY_STATUS_PROMISE(promise, std::move(result));
@ -15690,7 +15697,7 @@ void ContactsManager::get_chat_participant(ChatId chat_id, UserId user_id, Promi
return; return;
} }
if (is_chat_full_outdated(chat_full, c, chat_id)) { if (is_chat_full_outdated(chat_full, c, chat_id, true)) {
send_get_chat_full_query(chat_id, Auto(), "get_chat_participant lazy"); send_get_chat_full_query(chat_id, Auto(), "get_chat_participant lazy");
} }

View File

@ -1412,7 +1412,7 @@ class ContactsManager final : public Actor {
void update_channel_full(ChannelFull *channel_full, ChannelId channel_id, const char *source, void update_channel_full(ChannelFull *channel_full, ChannelId channel_id, const char *source,
bool from_database = false); bool from_database = false);
static bool is_chat_full_outdated(const ChatFull *chat_full, const Chat *c, ChatId chat_id); bool is_chat_full_outdated(const ChatFull *chat_full, const Chat *c, ChatId chat_id, bool only_participants) const;
bool is_user_contact(const User *u, UserId user_id, bool is_mutual) const; bool is_user_contact(const User *u, UserId user_id, bool is_mutual) const;