Add unread status in message threads.

GitOrigin-RevId: ed0fb2fc705b9539001b365fd5aa07d762d9a382
This commit is contained in:
levlam 2020-09-19 22:01:28 +03:00
parent 54ed8cfbc5
commit dad48976b5
6 changed files with 41 additions and 33 deletions

View File

@ -643,11 +643,12 @@ messageForwardInfo origin:MessageForwardOrigin date:int32 public_service_announc
//@description Contains information about interactions with a message
//@view_count Number of times the message was viewed
//@forward_count Number of times the message was forwarded
//@reply_count Number of times the message was directly or indirectly replied; discussion supergroups and discussed channels only
//@recent_replier_user_ids User identifiers of the recent repliers to the channel post
//@last_read_inbox_comment_message_id Identifier of the last read incoming comment to the channel post in the corresponding discussion supergroup
//@last_read_outbox_comment_message_id Identifier of the last read outgoing comment to the channel post in the corresponding discussion supergroup
messageInteractionInfo view_count:int32 forward_count:int32 reply_count:int32 recent_replier_user_ids:vector<int32> last_read_inbox_comment_message_id:int53 last_read_outbox_comment_message_id:int53 = MessageInteractionInfo;
//@reply_count Number of times the message was directly or indirectly replied; available in discussion supergroups and channels with a discussion supergroup
//@recent_replier_user_ids User identifiers of the recent repliers to the message; available in channels with a discussion supergroup
//@last_read_inbox_comment_message_id Identifier of the last read incoming comment to the message
//@last_read_outbox_comment_message_id Identifier of the last read outgoing comment to the message
//@last_comment_message_id Identifier of the last comment to the message
messageInteractionInfo view_count:int32 forward_count:int32 reply_count:int32 recent_replier_user_ids:vector<int32> last_read_inbox_comment_message_id:int53 last_read_outbox_comment_message_id:int53 last_comment_message_id:int53 = MessageInteractionInfo;
//@class MessageSendingState @description Contains information about the sending state of the message

Binary file not shown.

View File

@ -41,14 +41,14 @@ MessageReplyInfo::MessageReplyInfo(tl_object_ptr<telegram_api::messageReplies> &
LOG(ERROR) << "Receive " << dialog_id << " as a recent replier";
}
}
if ((reply_info->flags_ & telegram_api::messageReplies::MAX_ID_MASK) != 0 &&
ServerMessageId(reply_info->max_id_).is_valid()) {
max_message_id = MessageId(ServerMessageId(reply_info->max_id_));
}
if ((reply_info->flags_ & telegram_api::messageReplies::READ_MAX_ID_MASK) != 0 &&
ServerMessageId(reply_info->read_max_id_).is_valid()) {
last_read_inbox_message_id = MessageId(ServerMessageId(reply_info->read_max_id_));
}
}
if ((reply_info->flags_ & telegram_api::messageReplies::MAX_ID_MASK) != 0 &&
ServerMessageId(reply_info->max_id_).is_valid()) {
max_message_id = MessageId(ServerMessageId(reply_info->max_id_));
}
if ((reply_info->flags_ & telegram_api::messageReplies::READ_MAX_ID_MASK) != 0 &&
ServerMessageId(reply_info->read_max_id_).is_valid()) {
last_read_inbox_message_id = MessageId(ServerMessageId(reply_info->read_max_id_));
}
}
@ -60,10 +60,6 @@ bool MessageReplyInfo::need_update_to(const MessageReplyInfo &other) const {
}
bool MessageReplyInfo::update_max_message_ids(const MessageReplyInfo &other) {
if (!other.is_comment) {
return false;
}
return update_max_message_ids(other.max_message_id, other.last_read_inbox_message_id,
other.last_read_outbox_message_id);
}
@ -71,10 +67,6 @@ bool MessageReplyInfo::update_max_message_ids(const MessageReplyInfo &other) {
bool MessageReplyInfo::update_max_message_ids(MessageId other_max_message_id,
MessageId other_last_read_inbox_message_id,
MessageId other_last_read_outbox_message_id) {
if (!is_comment) {
return false;
}
bool result = false;
if (other_max_message_id > max_message_id) {
max_message_id = other_max_message_id;
@ -104,7 +96,7 @@ void MessageReplyInfo::add_reply(DialogId replier_dialog_id, MessageId reply_mes
}
}
if (is_comment && reply_message_id > max_message_id) {
if (reply_message_id > max_message_id) {
max_message_id = reply_message_id;
}
}
@ -115,7 +107,8 @@ StringBuilder &operator<<(StringBuilder &string_builder, const MessageReplyInfo
<< reply_info.recent_replier_dialog_ids << " read up to "
<< reply_info.last_read_inbox_message_id << "/" << reply_info.last_read_outbox_message_id;
} else {
return string_builder << reply_info.reply_count << " replies";
return string_builder << reply_info.reply_count << " replies read up to " << reply_info.last_read_inbox_message_id
<< "/" << reply_info.last_read_outbox_message_id;
}
}

View File

@ -22,9 +22,9 @@ struct MessageReplyInfo {
int32 pts = -1;
vector<DialogId> recent_replier_dialog_ids; // comments only
ChannelId channel_id; // comments only
MessageId max_message_id; // comments only
MessageId last_read_inbox_message_id; // comments only
MessageId last_read_outbox_message_id; // comments only
MessageId max_message_id;
MessageId last_read_inbox_message_id;
MessageId last_read_outbox_message_id;
bool is_comment = false;
MessageReplyInfo() = default;

View File

@ -443,8 +443,10 @@ class GetDiscussionMessageQuery : public Td::ResultHandler {
if ((ptr->flags_ & telegram_api::messages_discussionMessage::READ_OUTBOX_MAX_ID_MASK) != 0) {
last_read_outbox_message_id = MessageId(ServerMessageId(ptr->read_outbox_max_id_));
}
td->messages_manager_->on_update_read_message_comments(dialog_id_, message_id_, max_message_id,
last_read_inbox_message_id, last_read_outbox_message_id);
if (DialogId(expected_channel_id_) != dialog_id_) {
td->messages_manager_->on_update_read_message_comments(dialog_id_, message_id_, max_message_id,
last_read_inbox_message_id, last_read_outbox_message_id);
}
vector<FullMessageId> full_message_ids;
for (auto &message : ptr->messages_) {
@ -457,6 +459,11 @@ class GetDiscussionMessageQuery : public Td::ResultHandler {
}
}
}
if (!full_message_ids.empty()) {
td->messages_manager_->on_update_read_message_comments(full_message_ids.back().get_dialog_id(),
full_message_ids.back().get_message_id(), max_message_id,
last_read_inbox_message_id, last_read_outbox_message_id);
}
promise_.set_value(std::move(full_message_ids));
}
@ -6302,6 +6309,7 @@ td_api::object_ptr<td_api::messageInteractionInfo> MessagesManager::get_message_
vector<UserId> recent_replier_user_ids;
MessageId last_read_inbox_message_id;
MessageId last_read_outbox_message_id;
MessageId max_message_id;
if (is_active_reply_info) {
reply_count = m->reply_info.reply_count;
for (auto recent_replier_dialog_id : m->reply_info.recent_replier_dialog_ids) {
@ -6311,12 +6319,13 @@ td_api::object_ptr<td_api::messageInteractionInfo> MessagesManager::get_message_
}
last_read_inbox_message_id = m->reply_info.last_read_inbox_message_id;
last_read_outbox_message_id = m->reply_info.last_read_outbox_message_id;
max_message_id = m->reply_info.max_message_id;
}
return td_api::make_object<td_api::messageInteractionInfo>(
m->view_count, m->forward_count, reply_count,
td_->contacts_manager_->get_user_ids_object(recent_replier_user_ids, "get_message_interaction_info_object"),
last_read_inbox_message_id.get(), last_read_outbox_message_id.get());
last_read_inbox_message_id.get(), last_read_outbox_message_id.get(), max_message_id.get());
}
bool MessagesManager::update_message_interaction_info(DialogId dialog_id, Message *m, int32 view_count,

View File

@ -1722,15 +1722,20 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateChannelAvailabl
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateReadChannelDiscussionInbox> update,
bool /*force_apply*/) {
td_->messages_manager_->on_update_read_message_comments(
DialogId(ChannelId(update->channel_id_)), MessageId(ServerMessageId(update->top_msg_id_)),
MessageId(ServerMessageId(update->top_msg_id_)), MessageId(ServerMessageId(update->read_max_id_)), MessageId());
DialogId(ChannelId(update->channel_id_)), MessageId(ServerMessageId(update->top_msg_id_)), MessageId(),
MessageId(ServerMessageId(update->read_max_id_)), MessageId());
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(),
MessageId(ServerMessageId(update->read_max_id_)), MessageId());
}
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateReadChannelDiscussionOutbox> update,
bool /*force_apply*/) {
td_->messages_manager_->on_update_read_message_comments(
DialogId(ChannelId(update->channel_id_)), MessageId(ServerMessageId(update->top_msg_id_)),
MessageId(ServerMessageId(update->top_msg_id_)), MessageId(), MessageId(ServerMessageId(update->read_max_id_)));
DialogId(ChannelId(update->channel_id_)), MessageId(ServerMessageId(update->top_msg_id_)), MessageId(),
MessageId(), MessageId(ServerMessageId(update->read_max_id_)));
}
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateUserPinnedMessage> update, bool /*force_apply*/) {