Repair unread mention count in channels when a mention is read.
This commit is contained in:
parent
4b538adbdb
commit
c4b7100ad8
@ -5572,6 +5572,7 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
|
|||||||
STORE_FLAG(has_history_generation);
|
STORE_FLAG(has_history_generation);
|
||||||
STORE_FLAG(need_repair_unread_reaction_count);
|
STORE_FLAG(need_repair_unread_reaction_count);
|
||||||
STORE_FLAG(is_translatable);
|
STORE_FLAG(is_translatable);
|
||||||
|
STORE_FLAG(need_repair_unread_mention_count);
|
||||||
END_STORE_FLAGS();
|
END_STORE_FLAGS();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5836,6 +5837,7 @@ void MessagesManager::Dialog::parse(ParserT &parser) {
|
|||||||
PARSE_FLAG(has_history_generation);
|
PARSE_FLAG(has_history_generation);
|
||||||
PARSE_FLAG(need_repair_unread_reaction_count);
|
PARSE_FLAG(need_repair_unread_reaction_count);
|
||||||
PARSE_FLAG(is_translatable);
|
PARSE_FLAG(is_translatable);
|
||||||
|
PARSE_FLAG(need_repair_unread_mention_count);
|
||||||
END_PARSE_FLAGS();
|
END_PARSE_FLAGS();
|
||||||
} else {
|
} else {
|
||||||
need_repair_action_bar = false;
|
need_repair_action_bar = false;
|
||||||
@ -12429,8 +12431,23 @@ void MessagesManager::read_channel_message_content_from_updates(Dialog *d, Messa
|
|||||||
Message *m = get_message_force(d, message_id, "read_channel_message_content_from_updates");
|
Message *m = get_message_force(d, message_id, "read_channel_message_content_from_updates");
|
||||||
if (m != nullptr) {
|
if (m != nullptr) {
|
||||||
read_message_content(d, m, false, "read_channel_message_content_from_updates");
|
read_message_content(d, m, false, "read_channel_message_content_from_updates");
|
||||||
} else if (message_id > d->last_new_message_id && d->last_new_message_id.is_valid()) {
|
} else {
|
||||||
get_channel_difference(d->dialog_id, d->pts, true, "read_channel_message_content_from_updates");
|
if (!have_input_peer(d->dialog_id, AccessRights::Read)) {
|
||||||
|
LOG(INFO) << "Ignore updateChannelReadMessagesContents in inaccessible " << d->dialog_id;
|
||||||
|
if (d->unread_mention_count != 0) {
|
||||||
|
set_dialog_unread_mention_count(d, 0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (message_id > d->last_new_message_id && d->last_new_message_id.is_valid()) {
|
||||||
|
get_channel_difference(d->dialog_id, d->pts, true, "read_channel_message_content_from_updates");
|
||||||
|
} else {
|
||||||
|
// there is no message, so the update can be ignored
|
||||||
|
if (d->unread_mention_count > 0) {
|
||||||
|
// but if the chat has unread mentions, then number of unread mentions could have been changed
|
||||||
|
repair_dialog_unread_mention_count(d, "read_channel_message_content_from_updates");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12604,6 +12621,20 @@ void MessagesManager::repair_dialog_unread_reaction_count(Dialog *d, Promise<Uni
|
|||||||
send_get_dialog_query(d->dialog_id, std::move(promise), 0, source);
|
send_get_dialog_query(d->dialog_id, std::move(promise), 0, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessagesManager::repair_dialog_unread_mention_count(Dialog *d, const char *source) {
|
||||||
|
CHECK(d != nullptr);
|
||||||
|
|
||||||
|
if (td_->auth_manager_->is_bot()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!d->need_repair_unread_mention_count) {
|
||||||
|
d->need_repair_unread_mention_count = true;
|
||||||
|
on_dialog_updated(d->dialog_id, "repair_dialog_unread_mention_count");
|
||||||
|
}
|
||||||
|
|
||||||
|
send_get_dialog_query(d->dialog_id, Promise<Unit>(), 0, source);
|
||||||
|
}
|
||||||
|
|
||||||
void MessagesManager::read_history_inbox(DialogId dialog_id, MessageId max_message_id, int32 unread_count,
|
void MessagesManager::read_history_inbox(DialogId dialog_id, MessageId max_message_id, int32 unread_count,
|
||||||
const char *source) {
|
const char *source) {
|
||||||
CHECK(!max_message_id.is_scheduled());
|
CHECK(!max_message_id.is_scheduled());
|
||||||
@ -16163,7 +16194,15 @@ void MessagesManager::on_get_dialogs(FolderId folder_id, vector<tl_object_ptr<te
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!G()->parameters().use_message_db || is_new) {
|
if (!G()->parameters().use_message_db || is_new || d->need_repair_unread_mention_count) {
|
||||||
|
if (d->need_repair_unread_mention_count) {
|
||||||
|
if (d->unread_mention_count != dialog->unread_mentions_count_) {
|
||||||
|
LOG(INFO) << "Repaired unread mention count in " << dialog_id << " from " << d->unread_mention_count << " to "
|
||||||
|
<< dialog->unread_mentions_count_;
|
||||||
|
}
|
||||||
|
d->need_repair_unread_mention_count = false;
|
||||||
|
on_dialog_updated(dialog_id, "repaired dialog unread mention count");
|
||||||
|
}
|
||||||
if (d->unread_mention_count != dialog->unread_mentions_count_) {
|
if (d->unread_mention_count != dialog->unread_mentions_count_) {
|
||||||
set_dialog_unread_mention_count(d, dialog->unread_mentions_count_);
|
set_dialog_unread_mention_count(d, dialog->unread_mentions_count_);
|
||||||
update_dialog_mention_notification_count(d);
|
update_dialog_mention_notification_count(d);
|
||||||
@ -16181,7 +16220,7 @@ void MessagesManager::on_get_dialogs(FolderId folder_id, vector<tl_object_ptr<te
|
|||||||
}
|
}
|
||||||
if (d->unread_reaction_count != dialog->unread_reactions_count_) {
|
if (d->unread_reaction_count != dialog->unread_reactions_count_) {
|
||||||
set_dialog_unread_reaction_count(d, dialog->unread_reactions_count_);
|
set_dialog_unread_reaction_count(d, dialog->unread_reactions_count_);
|
||||||
// update_dialog_mention_notification_count(d);
|
// update_dialog_reaction_notification_count(d);
|
||||||
send_update_chat_unread_reaction_count(d, source);
|
send_update_chat_unread_reaction_count(d, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38180,6 +38219,9 @@ void MessagesManager::fix_new_dialog(Dialog *d, unique_ptr<Message> &&last_datab
|
|||||||
if (d->need_repair_unread_reaction_count) {
|
if (d->need_repair_unread_reaction_count) {
|
||||||
repair_dialog_unread_reaction_count(d, Promise<Unit>(), "fix_new_dialog");
|
repair_dialog_unread_reaction_count(d, Promise<Unit>(), "fix_new_dialog");
|
||||||
}
|
}
|
||||||
|
if (d->need_repair_unread_mention_count) {
|
||||||
|
repair_dialog_unread_mention_count(d, "fix_new_dialog");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessagesManager::add_dialog_last_database_message(Dialog *d, unique_ptr<Message> &&last_database_message) {
|
bool MessagesManager::add_dialog_last_database_message(Dialog *d, unique_ptr<Message> &&last_database_message) {
|
||||||
|
@ -1390,6 +1390,7 @@ class MessagesManager final : public Actor {
|
|||||||
bool is_available_reactions_inited = false;
|
bool is_available_reactions_inited = false;
|
||||||
bool had_yet_unsent_message_id_overflow = false;
|
bool had_yet_unsent_message_id_overflow = false;
|
||||||
bool need_repair_unread_reaction_count = false;
|
bool need_repair_unread_reaction_count = false;
|
||||||
|
bool need_repair_unread_mention_count = false;
|
||||||
bool is_translatable = false;
|
bool is_translatable = false;
|
||||||
|
|
||||||
bool increment_view_counter = false;
|
bool increment_view_counter = false;
|
||||||
@ -2272,6 +2273,8 @@ class MessagesManager final : public Actor {
|
|||||||
|
|
||||||
void repair_dialog_unread_reaction_count(Dialog *d, Promise<Unit> &&promise, const char *source);
|
void repair_dialog_unread_reaction_count(Dialog *d, Promise<Unit> &&promise, const char *source);
|
||||||
|
|
||||||
|
void repair_dialog_unread_mention_count(Dialog *d, const char *source);
|
||||||
|
|
||||||
void read_history_outbox(DialogId dialog_id, MessageId max_message_id, int32 read_date = -1);
|
void read_history_outbox(DialogId dialog_id, MessageId max_message_id, int32 read_date = -1);
|
||||||
|
|
||||||
void read_history_on_server(Dialog *d, MessageId max_message_id);
|
void read_history_on_server(Dialog *d, MessageId max_message_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user