Update order of channel stories when they are joined or left.

This commit is contained in:
levlam 2023-09-05 19:14:40 +03:00
parent 08fc889997
commit b42781a631
2 changed files with 13 additions and 4 deletions

View File

@ -16387,14 +16387,23 @@ void ContactsManager::on_channel_status_changed(Channel *c, ChannelId channel_id
send_closure_later(G()->messages_manager(), &MessagesManager::on_update_dialog_group_call_rights,
DialogId(channel_id));
}
if (td_->auth_manager_->is_bot() && old_status.is_administrator() && !new_status.is_administrator()) {
bool is_bot = td_->auth_manager_->is_bot();
if (is_bot && old_status.is_administrator() && !new_status.is_administrator()) {
channel_participants_.erase(channel_id);
}
if (td_->auth_manager_->is_bot() && old_status.is_member() && !new_status.is_member() &&
!G()->use_message_database()) {
if (is_bot && old_status.is_member() && !new_status.is_member() && !G()->use_message_database()) {
send_closure_later(G()->messages_manager(), &MessagesManager::on_dialog_deleted, DialogId(channel_id),
Promise<Unit>());
}
if (!is_bot && old_status.is_member() != new_status.is_member()) {
if (new_status.is_member()) {
send_closure_later(td_->story_manager_actor_, &StoryManager::reload_dialog_expiring_stories,
DialogId(channel_id));
} else {
send_closure_later(td_->story_manager_actor_, &StoryManager::on_dialog_active_stories_order_updated,
DialogId(channel_id), "on_channel_status_changed");
}
}
// must not load ChannelFull, because must not change the Channel
CHECK(have_channel_full == (get_channel_full(channel_id) != nullptr));

View File

@ -3994,7 +3994,7 @@ StoryListId StoryManager::get_dialog_story_list_id(DialogId owner_dialog_id) con
void StoryManager::on_dialog_active_stories_order_updated(DialogId owner_dialog_id, const char *source) {
LOG(INFO) << "Update order of active stories in " << owner_dialog_id << " from " << source;
// called from update_user, must not create the dialog and hence must not load active stories
// called from update_user/on_channel_status_changed, must not create the dialog and hence must not load active stories
auto active_stories = get_active_stories_editable(owner_dialog_id);
bool need_save_to_database = false;
if (active_stories != nullptr &&