Update last read inbox/outbox message identifiers in topics.
This commit is contained in:
parent
848de33676
commit
f97c103e2b
@ -42,6 +42,25 @@ ForumTopic::ForumTopic(Td *td, tl_object_ptr<telegram_api::ForumTopic> &&forum_t
|
||||
unread_reaction_count_ = forum_topic->unread_reactions_count_;
|
||||
}
|
||||
|
||||
bool ForumTopic::update_last_read_outbox_message_id(MessageId last_read_outbox_message_id) {
|
||||
if (last_read_outbox_message_id <= last_read_outbox_message_id_) {
|
||||
return false;
|
||||
}
|
||||
last_read_outbox_message_id_ = last_read_outbox_message_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ForumTopic::update_last_read_inbox_message_id(MessageId last_read_inbox_message_id, int32 unread_count) {
|
||||
if (last_read_inbox_message_id <= last_read_inbox_message_id_) {
|
||||
return false;
|
||||
}
|
||||
last_read_inbox_message_id_ = last_read_inbox_message_id;
|
||||
if (unread_count >= 0) {
|
||||
unread_count_ = unread_count;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::forumTopic> ForumTopic::get_forum_topic_object(Td *td, DialogId dialog_id,
|
||||
const ForumTopicInfo &info) const {
|
||||
if (info.is_empty()) {
|
||||
|
@ -42,6 +42,10 @@ class ForumTopic {
|
||||
return is_short_;
|
||||
}
|
||||
|
||||
bool update_last_read_outbox_message_id(MessageId last_read_outbox_message_id);
|
||||
|
||||
bool update_last_read_inbox_message_id(MessageId last_read_inbox_message_id, int32 unread_count);
|
||||
|
||||
DialogNotificationSettings *get_notification_settings() {
|
||||
return ¬ification_settings_;
|
||||
}
|
||||
|
@ -456,6 +456,26 @@ void ForumTopicManager::edit_forum_topic(DialogId dialog_id, MessageId top_threa
|
||||
->send(channel_id, top_thread_message_id, edit_title, new_title, edit_icon_custom_emoji, icon_custom_emoji_id);
|
||||
}
|
||||
|
||||
void ForumTopicManager::on_update_forum_topic_unread(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
MessageId last_message_id, MessageId last_read_inbox_message_id,
|
||||
MessageId last_read_outbox_message_id, int32 unread_count) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto topic = get_topic(dialog_id, top_thread_message_id);
|
||||
if (topic == nullptr || topic->topic_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (topic->topic_->update_last_read_outbox_message_id(last_read_outbox_message_id)) {
|
||||
// TODO send updates
|
||||
}
|
||||
if (topic->topic_->update_last_read_inbox_message_id(last_read_inbox_message_id, unread_count)) {
|
||||
// TODO send updates
|
||||
}
|
||||
}
|
||||
|
||||
DialogNotificationSettings *ForumTopicManager::get_forum_topic_notification_settings(DialogId dialog_id,
|
||||
MessageId top_thread_message_id) {
|
||||
auto topic = get_topic(dialog_id, top_thread_message_id);
|
||||
|
@ -81,6 +81,10 @@ class ForumTopicManager final : public Actor {
|
||||
|
||||
void delete_all_dialog_topics(DialogId dialog_id);
|
||||
|
||||
void on_update_forum_topic_unread(DialogId dialog_id, MessageId top_thread_message_id, MessageId last_message_id,
|
||||
MessageId last_read_inbox_message_id, MessageId last_read_outbox_message_id,
|
||||
int32 unread_count);
|
||||
|
||||
void on_update_forum_topic_notify_settings(DialogId dialog_id, MessageId top_thread_message_id,
|
||||
tl_object_ptr<telegram_api::peerNotifySettings> &&peer_notify_settings,
|
||||
const char *source);
|
||||
|
@ -6830,7 +6830,7 @@ void MessagesManager::on_update_read_channel_messages_contents(
|
||||
|
||||
void MessagesManager::on_update_read_message_comments(DialogId dialog_id, MessageId message_id,
|
||||
MessageId max_message_id, MessageId last_read_inbox_message_id,
|
||||
MessageId last_read_outbox_message_id) {
|
||||
MessageId last_read_outbox_message_id, int32 unread_count) {
|
||||
Dialog *d = get_dialog_force(dialog_id, "on_update_read_message_comments");
|
||||
if (d == nullptr) {
|
||||
LOG(INFO) << "Ignore update of read message comments in unknown " << dialog_id << " in updateReadDiscussion";
|
||||
@ -6838,8 +6838,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 ||
|
||||
!is_active_message_reply_info(dialog_id, m->reply_info)) {
|
||||
if (m == nullptr || !m->message_id.is_server() || m->top_thread_message_id != m->message_id) {
|
||||
return;
|
||||
}
|
||||
if (m->is_topic_message) {
|
||||
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);
|
||||
}
|
||||
if (!is_active_message_reply_info(dialog_id, m->reply_info)) {
|
||||
return;
|
||||
}
|
||||
if (m->reply_info.update_max_message_ids(max_message_id, last_read_inbox_message_id, last_read_outbox_message_id)) {
|
||||
@ -18590,11 +18596,11 @@ void MessagesManager::process_discussion_message_impl(
|
||||
auto last_read_outbox_message_id = MessageId(ServerMessageId(result->read_outbox_max_id_));
|
||||
if (top_message_id.is_valid()) {
|
||||
on_update_read_message_comments(expected_dialog_id, top_message_id, max_message_id, last_read_inbox_message_id,
|
||||
last_read_outbox_message_id);
|
||||
last_read_outbox_message_id, message_thread_info.unread_message_count);
|
||||
}
|
||||
if (expected_dialog_id != dialog_id) {
|
||||
on_update_read_message_comments(dialog_id, message_id, max_message_id, last_read_inbox_message_id,
|
||||
last_read_outbox_message_id);
|
||||
last_read_outbox_message_id, message_thread_info.unread_message_count);
|
||||
}
|
||||
promise.set_value(std::move(message_thread_info));
|
||||
}
|
||||
|
@ -325,7 +325,8 @@ class MessagesManager final : public Actor {
|
||||
tl_object_ptr<telegram_api::updateChannelReadMessagesContents> &&update);
|
||||
|
||||
void on_update_read_message_comments(DialogId dialog_id, MessageId message_id, MessageId max_message_id,
|
||||
MessageId last_read_inbox_message_id, MessageId last_read_outbox_message_id);
|
||||
MessageId last_read_inbox_message_id, MessageId last_read_outbox_message_id,
|
||||
int32 unread_count);
|
||||
|
||||
void on_update_channel_too_long(tl_object_ptr<telegram_api::updateChannelTooLong> &&update, bool force_apply);
|
||||
|
||||
|
@ -3013,11 +3013,11 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateReadChannelDisc
|
||||
}
|
||||
td_->messages_manager_->on_update_read_message_comments(DialogId(ChannelId(update->channel_id_)),
|
||||
MessageId(ServerMessageId(update->top_msg_id_)), MessageId(),
|
||||
last_read_inbox_message_id, MessageId());
|
||||
last_read_inbox_message_id, MessageId(), -1);
|
||||
if ((update->flags_ & telegram_api::updateReadChannelDiscussionInbox::BROADCAST_ID_MASK) != 0) {
|
||||
td_->messages_manager_->on_update_read_message_comments(DialogId(ChannelId(update->broadcast_id_)),
|
||||
MessageId(ServerMessageId(update->broadcast_post_)),
|
||||
MessageId(), last_read_inbox_message_id, MessageId());
|
||||
MessageId(), last_read_inbox_message_id, MessageId(), -1);
|
||||
}
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
@ -3031,7 +3031,7 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateReadChannelDisc
|
||||
}
|
||||
td_->messages_manager_->on_update_read_message_comments(DialogId(ChannelId(update->channel_id_)),
|
||||
MessageId(ServerMessageId(update->top_msg_id_)), MessageId(),
|
||||
MessageId(), last_read_outbox_message_id);
|
||||
MessageId(), last_read_outbox_message_id, -1);
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user