Skip to content

Fix update last read outbox and inbox messages for general topic #3306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion td/generate/scheme/td_api.tl
Original file line number Diff line number Diff line change
@@ -8354,9 +8354,10 @@ updateForumTopicInfo info:forumTopicInfo = Update;
//@chat_id Chat identifier
//@message_thread_id Message thread identifier of the topic
//@is_pinned True, if the topic is pinned in the topic list
//@last_read_inbox_message_id Identifier of the last read incoming message
//@last_read_outbox_message_id Identifier of the last read outgoing message
//@notification_settings Notification settings for the topic
updateForumTopic chat_id:int53 message_thread_id:int53 is_pinned:Bool last_read_outbox_message_id:int53 notification_settings:chatNotificationSettings = Update;
updateForumTopic chat_id:int53 message_thread_id:int53 is_pinned:Bool last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 notification_settings:chatNotificationSettings = Update;

//@description Notification settings for some type of chats were updated @scope Types of chats for which notification settings were updated @notification_settings The new notification settings
updateScopeNotificationSettings scope:NotificationSettingsScope notification_settings:scopeNotificationSettings = Update;
3 changes: 2 additions & 1 deletion td/telegram/ForumTopic.cpp
Original file line number Diff line number Diff line change
@@ -103,7 +103,8 @@ td_api::object_ptr<td_api::updateForumTopic> ForumTopic::get_update_forum_topic_
Td *td, DialogId dialog_id, MessageId top_thread_message_id) const {
return td_api::make_object<td_api::updateForumTopic>(
td->dialog_manager_->get_chat_id_object(dialog_id, "updateForumTopic"), top_thread_message_id.get(), is_pinned_,
last_read_outbox_message_id_.get(), get_chat_notification_settings_object(&notification_settings_));
last_read_inbox_message_id_.get(), last_read_outbox_message_id_.get(),
get_chat_notification_settings_object(&notification_settings_));
}

} // namespace td
8 changes: 6 additions & 2 deletions td/telegram/ForumTopicManager.cpp
Original file line number Diff line number Diff line change
@@ -578,13 +578,17 @@ void ForumTopicManager::read_forum_topic_messages(DialogId dialog_id, MessageId
return;
}

bool need_update = false;
if (topic->topic_->update_last_read_inbox_message_id(last_read_inbox_message_id, -1)) {
// TODO send updates
need_update = true;
auto max_message_id = last_read_inbox_message_id.get_prev_server_message_id();
LOG(INFO) << "Send read topic history request in topic of " << top_thread_message_id << " in " << dialog_id
<< " up to " << max_message_id;
td_->create_handler<ReadForumTopicQuery>()->send(dialog_id, top_thread_message_id, max_message_id);
}
if (need_update) {
on_forum_topic_changed(dialog_id, topic);
}
}

void ForumTopicManager::on_update_forum_topic_unread(DialogId dialog_id, MessageId top_thread_message_id,
@@ -604,7 +608,7 @@ void ForumTopicManager::on_update_forum_topic_unread(DialogId dialog_id, Message
need_update = true;
}
if (topic->topic_->update_last_read_inbox_message_id(last_read_inbox_message_id, unread_count)) {
// TODO send updates
need_update = true;
}
if (need_update) {
on_forum_topic_changed(dialog_id, topic);
6 changes: 4 additions & 2 deletions td/telegram/MessagesManager.cpp
Original file line number Diff line number Diff line change
@@ -4308,12 +4308,14 @@ void MessagesManager::on_update_read_message_comments(DialogId dialog_id, Messag
}

auto m = get_message_force(d, message_id, "on_update_read_message_comments");
if (m == nullptr || !m->message_id.is_server() || m->top_thread_message_id != m->message_id) {
if (m == nullptr || !m->message_id.is_server()) {
return;
}
if (m->is_topic_message) {
if (m->is_topic_message || (d->is_forum && m->message_id == MessageId(ServerMessageId(1)))) {
td_->forum_topic_manager_->on_update_forum_topic_unread(
dialog_id, message_id, max_message_id, last_read_inbox_message_id, last_read_outbox_message_id, unread_count);
} else if (m->top_thread_message_id != m->message_id) {
return;
}
if (!is_active_message_reply_info(dialog_id, m->reply_info)) {
return;