Update story order when user.is_premium changes.

This commit is contained in:
levlam 2023-06-30 14:41:39 +03:00
parent ab04885dc4
commit 6bd9aea325
4 changed files with 11 additions and 18 deletions

View File

@ -10376,6 +10376,7 @@ void ContactsManager::on_get_user(tl_object_ptr<telegram_api::User> &&user_ptr,
}
if (is_premium != u->is_premium) {
u->is_premium = is_premium;
u->is_is_premium_changed = true;
u->is_changed = true;
u->is_full_info_changed = true;
}
@ -11891,7 +11892,7 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo
}
if (u->is_is_contact_changed) {
td_->messages_manager_->on_dialog_user_is_contact_updated(DialogId(user_id), u->is_contact);
td_->story_manager_->on_dialog_user_is_contact_updated(DialogId(user_id));
td_->story_manager_->on_dialog_active_stories_order_updated(DialogId(user_id));
if (is_user_contact(u, user_id, false)) {
auto user_full = get_user_full(user_id);
if (user_full != nullptr && user_full->need_phone_number_privacy_exception) {
@ -11912,6 +11913,10 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo
}
u->is_is_deleted_changed = false;
}
if (u->is_is_premium_changed) {
td_->story_manager_->on_dialog_active_stories_order_updated(DialogId(user_id));
u->is_is_premium_changed = false;
}
if (u->is_name_changed) {
auto messages_manager = td_->messages_manager_.get();
messages_manager->on_dialog_title_updated(DialogId(user_id));
@ -11946,7 +11951,7 @@ void ContactsManager::update_user(User *u, UserId user_id, bool from_binlog, boo
}
}
if (u->is_stories_hidden_changed) {
td_->story_manager_->on_dialog_stories_hidden_updated(DialogId(user_id));
td_->story_manager_->on_dialog_active_stories_order_updated(DialogId(user_id));
u->is_stories_hidden_changed = false;
}
if (!td_->auth_manager_->is_bot()) {

View File

@ -799,6 +799,7 @@ class ContactsManager final : public Actor {
bool is_phone_number_changed = true;
bool is_is_contact_changed = true;
bool is_is_deleted_changed = true;
bool is_is_premium_changed = true;
bool is_stories_hidden_changed = true;
bool is_full_info_changed = false;
bool is_changed = true; // have new changes that need to be sent to the client and database

View File

@ -2197,24 +2197,13 @@ bool StoryManager::is_subscribed_to_dialog_stories(DialogId owner_dialog_id) con
}
}
void StoryManager::on_dialog_user_is_contact_updated(DialogId owner_dialog_id) {
void StoryManager::on_dialog_active_stories_order_updated(DialogId owner_dialog_id) {
auto active_stories = get_active_stories_editable(owner_dialog_id);
if (active_stories != nullptr) {
update_active_stories_order(owner_dialog_id, active_stories);
if (active_stories != nullptr && update_active_stories_order(owner_dialog_id, active_stories)) {
send_update_active_stories(owner_dialog_id);
}
}
void StoryManager::on_dialog_stories_hidden_updated(DialogId owner_dialog_id) {
auto active_stories = get_active_stories_editable(owner_dialog_id);
if (active_stories != nullptr) {
update_active_stories_order(owner_dialog_id, active_stories);
if (is_subscribed_to_dialog_stories(owner_dialog_id)) {
send_update_active_stories(owner_dialog_id);
}
}
}
void StoryManager::on_get_story_views(const vector<StoryId> &story_ids,
telegram_api::object_ptr<telegram_api::stories_storyViews> &&story_views) {
schedule_interaction_info_update();

View File

@ -164,9 +164,7 @@ class StoryManager final : public Actor {
bool on_update_read_stories(DialogId owner_dialog_id, StoryId max_read_story_id);
void on_dialog_user_is_contact_updated(DialogId owner_dialog_id);
void on_dialog_stories_hidden_updated(DialogId owner_dialog_id);
void on_dialog_active_stories_order_updated(DialogId owner_dialog_id);
Status can_get_story_viewers(StoryFullId story_full_id, const Story *story) const;