diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index 54b848052..023efeead 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -12135,6 +12135,13 @@ void ContactsManager::update_chat(Chat *c, ChatId chat_id, bool from_binlog, boo if (!from_database) { // if the chat is empty, this can add it to a chat list or remove it from a chat list send_closure_later(G()->messages_manager(), &MessagesManager::try_update_dialog_pos, DialogId(chat_id)); + + // reload the chat to repair its status if it is changed back after receiving of outdated data + create_actor("ReloadChatSleepActor", 1.0, + PromiseCreator::lambda([actor_id = actor_id(this), chat_id](Unit) { + send_closure(actor_id, &ContactsManager::reload_chat, chat_id, Promise()); + })) + .release(); } c->is_status_changed = false; } @@ -12227,6 +12234,14 @@ void ContactsManager::update_channel(Channel *c, ChannelId channel_id, bool from if (!c->status.can_manage_invite_links()) { td_->messages_manager_->drop_dialog_pending_join_requests(DialogId(channel_id)); } + if (!from_database) { + // reload the channel to repair its status if it is changed back after receiving of outdated data + create_actor("ReloadChannelSleepActor", 1.0, + PromiseCreator::lambda([actor_id = actor_id(this), channel_id](Unit) { + send_closure(actor_id, &ContactsManager::reload_channel, channel_id, Promise()); + })) + .release(); + } c->is_status_changed = false; } if (c->is_username_changed) { @@ -17146,6 +17161,8 @@ bool ContactsManager::get_chat(ChatId chat_id, int left_tries, Promise &&p } void ContactsManager::reload_chat(ChatId chat_id, Promise &&promise) { + TRY_STATUS_PROMISE(promise, G()->close_status()); + if (!chat_id.is_valid()) { return promise.set_error(Status::Error(400, "Invalid basic group identifier")); } @@ -17574,6 +17591,8 @@ bool ContactsManager::get_channel(ChannelId channel_id, int left_tries, Promise< } void ContactsManager::reload_channel(ChannelId channel_id, Promise &&promise) { + TRY_STATUS_PROMISE(promise, G()->close_status()); + if (!channel_id.is_valid()) { return promise.set_error(Status::Error(400, "Invalid supergroup identifier")); }