Add and use ContactsManager::on_update_user_max_read_story_id.
This commit is contained in:
parent
cb8418f840
commit
fdcec41c93
@ -13517,6 +13517,29 @@ void ContactsManager::on_update_user_has_stories(User *u, UserId user_id, bool h
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_user_max_read_story_id(UserId user_id, StoryId max_read_story_id) {
|
||||
CHECK(user_id.is_valid());
|
||||
|
||||
User *u = get_user(user_id);
|
||||
if (u != nullptr) {
|
||||
on_update_user_max_read_story_id(u, user_id, max_read_story_id);
|
||||
update_user(u, user_id);
|
||||
} else {
|
||||
LOG(ERROR) << "Ignore update user max_read_story_id about unknown " << user_id;
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_user_max_read_story_id(User *u, UserId user_id, StoryId max_read_story_id) {
|
||||
auto has_unread_stories = get_has_unread_stories(u);
|
||||
if (max_read_story_id.get() > u->max_read_story_id.get()) {
|
||||
u->max_read_story_id = max_read_story_id;
|
||||
u->need_save_to_database = true;
|
||||
}
|
||||
if (has_unread_stories != get_has_unread_stories(u)) {
|
||||
u->is_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ContactsManager::on_update_user_stories_hidden(UserId user_id, bool stories_hidden) {
|
||||
if (!user_id.is_valid()) {
|
||||
LOG(ERROR) << "Receive invalid " << user_id;
|
||||
|
@ -189,6 +189,7 @@ class ContactsManager final : public Actor {
|
||||
void on_update_user_emoji_status(UserId user_id, tl_object_ptr<telegram_api::EmojiStatus> &&emoji_status);
|
||||
void on_update_user_has_stories(UserId user_id, bool has_stories, StoryId max_active_story_id,
|
||||
StoryId max_read_story_id);
|
||||
void on_update_user_max_read_story_id(UserId user_id, StoryId max_read_story_id);
|
||||
void on_update_user_stories_hidden(UserId user_id, bool stories_hidden);
|
||||
void on_update_user_online(UserId user_id, tl_object_ptr<telegram_api::UserStatus> &&status);
|
||||
void on_update_user_local_was_online(UserId user_id, int32 local_was_online);
|
||||
@ -1404,6 +1405,7 @@ class ContactsManager final : public Actor {
|
||||
void on_update_user_emoji_status(User *u, UserId user_id, EmojiStatus emoji_status);
|
||||
void on_update_user_has_stories(User *u, UserId user_id, bool has_stories, StoryId max_active_story_id,
|
||||
StoryId max_read_story_id);
|
||||
void on_update_user_max_read_story_id(User *u, UserId user_id, StoryId max_read_story_id);
|
||||
void on_update_user_stories_hidden(User *u, UserId user_id, bool stories_hidden);
|
||||
void on_update_user_is_contact(User *u, UserId user_id, bool is_contact, bool is_mutual_contact,
|
||||
bool is_close_friend);
|
||||
|
@ -2471,6 +2471,9 @@ bool StoryManager::on_update_read_stories(DialogId owner_dialog_id, StoryId max_
|
||||
auto old_max_read_story_id = max_read_story_ids_.get(owner_dialog_id);
|
||||
if (max_read_story_id.get() > old_max_read_story_id.get()) {
|
||||
max_read_story_ids_.set(owner_dialog_id, max_read_story_id);
|
||||
if (owner_dialog_id.get_type() == DialogType::User) {
|
||||
td_->contacts_manager_->on_update_user_max_read_story_id(owner_dialog_id.get_user_id(), max_read_story_id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if (max_read_story_id.get() > active_stories->max_read_story_id_.get()) {
|
||||
@ -3162,6 +3165,9 @@ void StoryManager::on_binlog_events(vector<BinlogEvent> &&events) {
|
||||
auto active_stories = get_active_stories(dialog_id);
|
||||
if (active_stories == nullptr) {
|
||||
max_read_story_ids_[dialog_id] = max_read_story_id;
|
||||
if (dialog_id.get_type() == DialogType::User) {
|
||||
td_->contacts_manager_->on_update_user_max_read_story_id(dialog_id.get_user_id(), max_read_story_id);
|
||||
}
|
||||
} else {
|
||||
auto story_ids = active_stories->story_ids_;
|
||||
on_update_active_stories(dialog_id, max_read_story_id, std::move(story_ids));
|
||||
|
Loading…
Reference in New Issue
Block a user