Reload chat/channel with delay after status has changed.

This commit is contained in:
levlam 2023-07-24 13:43:21 +03:00
parent 1f6342c88e
commit 53c7cfbf02

View File

@ -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<SleepActor>("ReloadChatSleepActor", 1.0,
PromiseCreator::lambda([actor_id = actor_id(this), chat_id](Unit) {
send_closure(actor_id, &ContactsManager::reload_chat, chat_id, Promise<Unit>());
}))
.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<SleepActor>("ReloadChannelSleepActor", 1.0,
PromiseCreator::lambda([actor_id = actor_id(this), channel_id](Unit) {
send_closure(actor_id, &ContactsManager::reload_channel, channel_id, Promise<Unit>());
}))
.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<Unit> &&p
}
void ContactsManager::reload_chat(ChatId chat_id, Promise<Unit> &&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<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
if (!channel_id.is_valid()) {
return promise.set_error(Status::Error(400, "Invalid supergroup identifier"));
}