Add reply_count and recent_replier_user_ids to MessageIntercationInfo.

GitOrigin-RevId: 48bae463c091d3d29e3096ebb4c2fbbbeda38dfd
This commit is contained in:
levlam 2020-08-31 13:42:27 +03:00
parent b90e1bbeaf
commit ed782145bf
7 changed files with 221 additions and 32 deletions

View File

@ -578,7 +578,7 @@ supergroup id:int32 username:string date:int32 status:ChatMemberStatus member_co
//@can_set_username True, if the chat username can be changed
//@can_set_sticker_set True, if the supergroup sticker set can be changed
//@can_set_location True, if the supergroup location can be changed
//@can_get_statistics True, if the supergroup or channel statistics is available
//@can_get_statistics True, if the supergroup or channel statistics are available
//@is_all_history_available True, if new chat members will have access to old messages. In public or discussion groups and both public and private channels, old messages are always available, so this option affects only private supergroups without a linked chat. The value of this field is only available for chat administrators
//@sticker_set_id Identifier of the supergroup sticker set; 0 if none
//@location Location to which the supergroup is connected; may be null
@ -638,7 +638,9 @@ 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
messageInteractionInfo view_count:int32 forward_count:int32 = MessageInteractionInfo;
//@reply_count Number of times the message was directly or indirectly replied; supergroups and linked channels only
//@recent_replier_user_ids User identifiers of the recent repliers to the message
messageInteractionInfo view_count:int32 forward_count:int32 reply_count:int32 recent_replier_user_ids:vector<int32> = MessageInteractionInfo;
//@class MessageSendingState @description Contains information about the sending state of the message
@ -662,7 +664,8 @@ messageSendingStateFailed error_code:int32 error_message:string can_retry:Bool r
//@can_be_forwarded True, if the message can be forwarded
//@can_be_deleted_only_for_self True, if the message can be deleted only for the current user while other users will continue to see it
//@can_be_deleted_for_all_users True, if the message can be deleted for all users
//@can_get_statistics True, if the message statistics is available
//@can_get_statistics True, if the message statistics are available
//@can_get_replies True, if the message replies are available
//@is_channel_post True, if the message is a channel post. All messages to channels are channel posts, all other messages are not channel posts
//@contains_unread_mention True, if the message contains an unread mention for the current user
//@date Point in time (Unix timestamp) when the message was sent
@ -678,7 +681,7 @@ messageSendingStateFailed error_code:int32 error_message:string can_retry:Bool r
//@restriction_reason If non-empty, contains a human-readable description of the reason why access to this message must be restricted
//@content Content of the message
//@reply_markup Reply markup for the message; may be null
message id:int53 sender_user_id:int32 chat_id:int53 sending_state:MessageSendingState scheduling_state:MessageSchedulingState is_outgoing:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_get_statistics:Bool is_channel_post:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo interaction_info:messageInteractionInfo reply_to_message_id:int53 ttl:int32 ttl_expires_in:double via_bot_user_id:int32 author_signature:string media_album_id:int64 restriction_reason:string content:MessageContent reply_markup:ReplyMarkup = Message;
message id:int53 sender_user_id:int32 chat_id:int53 sending_state:MessageSendingState scheduling_state:MessageSchedulingState is_outgoing:Bool can_be_edited:Bool can_be_forwarded:Bool can_be_deleted_only_for_self:Bool can_be_deleted_for_all_users:Bool can_get_statistics:Bool can_get_replies:Bool is_channel_post:Bool contains_unread_mention:Bool date:int32 edit_date:int32 forward_info:messageForwardInfo interaction_info:messageInteractionInfo reply_to_message_id:int53 ttl:int32 ttl_expires_in:double via_bot_user_id:int32 author_signature:string media_album_id:int64 restriction_reason:string content:MessageContent reply_markup:ReplyMarkup = Message;
//@description Contains a list of messages @total_count Approximate total count of messages found @messages List of messages; messages may be null
messages total_count:int32 messages:vector<message> = Messages;
@ -2829,7 +2832,7 @@ networkStatisticsEntryFile file_type:FileType network_type:NetworkType sent_byte
//@sent_bytes Total number of bytes sent @received_bytes Total number of bytes received @duration Total call duration, in seconds
networkStatisticsEntryCall network_type:NetworkType sent_bytes:int53 received_bytes:int53 duration:double = NetworkStatisticsEntry;
//@description A full list of available network statistic entries @since_date Point in time (Unix timestamp) from which the statistics is collected @entries Network statistics entries
//@description A full list of available network statistic entries @since_date Point in time (Unix timestamp) from which the statistics are collected @entries Network statistics entries
networkStatistics since_date:int32 entries:vector<NetworkStatisticsEntry> = NetworkStatistics;
@ -4500,7 +4503,7 @@ removeChatActionBar chat_id:int53 = Ok;
reportChat chat_id:int53 reason:ChatReportReason message_ids:vector<int53> = Ok;
//@description Returns an HTTP URL with the chat statistics. Currently this method of getting the statistics is disabled and can be deleted in the future @chat_id Chat identifier @parameters Parameters from "tg://statsrefresh?params=******" link @is_dark Pass true if a URL with the dark theme must be returned
//@description Returns an HTTP URL with the chat statistics. Currently this method of getting the statistics are disabled and can be deleted in the future @chat_id Chat identifier @parameters Parameters from "tg://statsrefresh?params=******" link @is_dark Pass true if a URL with the dark theme must be returned
getChatStatisticsUrl chat_id:int53 parameters:string is_dark:Bool = HttpUrl;
//@description Returns detailed statistics about a chat. Currently this method can be used only for supergroups and channels. Can be used only if SupergroupFullInfo.can_get_statistics == true @chat_id Chat identifier @is_dark Pass true if a dark theme is used by the application

Binary file not shown.

View File

@ -2876,7 +2876,8 @@ class GetBroadcastStatsQuery : public Td::ResultHandler {
auto result = ContactsManager::convert_broadcast_stats(result_ptr.move_as_ok());
for (auto &info : result->recent_message_interactions_) {
td->messages_manager_->on_update_message_interaction_info({DialogId(channel_id_), MessageId(info->message_id_)},
info->view_count_, info->forward_count_);
info->view_count_, info->forward_count_, false,
nullptr);
}
promise_.set_value(std::move(result));
}
@ -13008,6 +13009,18 @@ bool ContactsManager::get_channel_sign_messages(const Channel *c) {
return c->sign_messages;
}
bool ContactsManager::get_channel_has_linked_channel(ChannelId channel_id) const {
auto c = get_channel(channel_id);
if (c == nullptr) {
return false;
}
return get_channel_has_linked_channel(c);
}
bool ContactsManager::get_channel_has_linked_channel(const Channel *c) {
return c->has_linked_channel;
}
int32 ContactsManager::get_channel_slow_mode_delay(ChannelId channel_id) {
auto channel_full = get_channel_full_force(channel_id, "get_channel_slow_mode_delay");
if (channel_full == nullptr) {

View File

@ -492,6 +492,7 @@ class ContactsManager : public Actor {
DialogParticipantStatus get_channel_permissions(ChannelId channel_id) const;
int32 get_channel_participant_count(ChannelId channel_id) const;
bool get_channel_sign_messages(ChannelId channel_id) const;
bool get_channel_has_linked_channel(ChannelId channel_id) const;
int32 get_channel_slow_mode_delay(ChannelId channel_id);
std::pair<int32, vector<UserId>> search_among_users(const vector<UserId> &user_ids, const string &query, int32 limit);
@ -1124,6 +1125,7 @@ class ContactsManager : public Actor {
static DialogParticipantStatus get_channel_status(const Channel *c);
DialogParticipantStatus get_channel_permissions(const Channel *c) const;
static bool get_channel_sign_messages(const Channel *c);
static bool get_channel_has_linked_channel(const Channel *c);
void set_my_id(UserId my_id);

View File

@ -1281,18 +1281,22 @@ class GetMessagesViewsQuery : public Td::ResultHandler {
}
auto result = result_ptr.move_as_ok();
td->contacts_manager_->on_get_users(std::move(result->users_), "GetMessagesViewsQuery");
if (!td->auth_manager_->is_bot()) {
td->contacts_manager_->on_get_users(std::move(result->users_), "GetMessagesViewsQuery");
}
auto interaction_infos = std::move(result->views_);
if (message_ids_.size() != interaction_infos.size()) {
return on_error(id, Status::Error(500, "Wrong number of message views returned"));
}
for (size_t i = 0; i < message_ids_.size(); i++) {
const auto *info = interaction_infos[i].get();
FullMessageId full_message_id{dialog_id_, message_ids_[i]};
auto *info = interaction_infos[i].get();
auto flags = info->flags_;
auto view_count = (flags & telegram_api::messageViews::VIEWS_MASK) != 0 ? info->views_ : 0;
auto forward_count = (flags & telegram_api::messageViews::FORWARDS_MASK) != 0 ? info->forwards_ : 0;
td->messages_manager_->on_update_message_interaction_info({dialog_id_, message_ids_[i]}, view_count,
forward_count);
td->messages_manager_->on_update_message_interaction_info(full_message_id, view_count, forward_count, true,
std::move(info->replies_));
}
}
@ -4179,6 +4183,7 @@ void MessagesManager::Message::store(StorerT &storer) const {
bool has_restriction_reasons = !restriction_reasons.empty();
bool has_forward_psa_type = is_forwarded && !forward_info->psa_type.empty();
bool has_forward_count = forward_count > 0;
bool has_reply_info = !reply_info.is_empty();
BEGIN_STORE_FLAGS();
STORE_FLAG(is_channel_post);
STORE_FLAG(is_outgoing);
@ -4228,6 +4233,7 @@ void MessagesManager::Message::store(StorerT &storer) const {
STORE_FLAG(is_copy);
STORE_FLAG(has_forward_psa_type);
STORE_FLAG(has_forward_count);
STORE_FLAG(has_reply_info);
END_STORE_FLAGS();
}
@ -4283,6 +4289,9 @@ void MessagesManager::Message::store(StorerT &storer) const {
if (has_forward_count) {
store(forward_count, storer);
}
if (has_reply_info) {
store(reply_info, storer);
}
if (has_ttl) {
store(ttl, storer);
store_time(ttl_expires_at, storer);
@ -4343,6 +4352,7 @@ void MessagesManager::Message::parse(ParserT &parser) {
bool has_restriction_reasons = false;
bool has_forward_psa_type = false;
bool has_forward_count = false;
bool has_reply_info = false;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_channel_post);
PARSE_FLAG(is_outgoing);
@ -4392,6 +4402,7 @@ void MessagesManager::Message::parse(ParserT &parser) {
PARSE_FLAG(is_copy);
PARSE_FLAG(has_forward_psa_type);
PARSE_FLAG(has_forward_count);
PARSE_FLAG(has_reply_info);
END_PARSE_FLAGS();
}
@ -4453,6 +4464,9 @@ void MessagesManager::Message::parse(ParserT &parser) {
if (has_forward_count) {
parse(forward_count, parser);
}
if (has_reply_info) {
parse(reply_info, parser);
}
if (has_ttl) {
parse(ttl, parser);
parse_time(ttl_expires_at, parser);
@ -6005,7 +6019,7 @@ void MessagesManager::on_update_message_view_count(FullMessageId full_message_id
LOG(ERROR) << "Receive " << view_count << " views in updateChannelMessageViews for " << full_message_id;
return;
}
update_message_interaction_info(full_message_id, view_count, -1);
update_message_interaction_info(full_message_id, view_count, -1, false, nullptr);
}
void MessagesManager::on_update_message_forward_count(FullMessageId full_message_id, int32 forward_count) {
@ -6013,16 +6027,17 @@ void MessagesManager::on_update_message_forward_count(FullMessageId full_message
LOG(ERROR) << "Receive " << forward_count << " forwards in updateChannelMessageForwards for " << full_message_id;
return;
}
update_message_interaction_info(full_message_id, -1, forward_count);
update_message_interaction_info(full_message_id, -1, forward_count, false, nullptr);
}
void MessagesManager::on_update_message_interaction_info(FullMessageId full_message_id, int32 view_count,
int32 forward_count) {
int32 forward_count, bool has_reply_info,
tl_object_ptr<telegram_api::messageReplies> &&reply_info) {
if (view_count < 0 || forward_count < 0) {
LOG(ERROR) << "Receive " << view_count << "/" << forward_count << " interaction counters for " << full_message_id;
return;
}
update_message_interaction_info(full_message_id, view_count, forward_count);
update_message_interaction_info(full_message_id, view_count, forward_count, has_reply_info, std::move(reply_info));
}
void MessagesManager::on_pending_message_views_timeout(DialogId dialog_id) {
@ -6051,7 +6066,8 @@ void MessagesManager::on_pending_message_views_timeout(DialogId dialog_id) {
}
void MessagesManager::update_message_interaction_info(FullMessageId full_message_id, int32 view_count,
int32 forward_count) {
int32 forward_count, bool has_reply_info,
tl_object_ptr<telegram_api::messageReplies> &&reply_info) {
auto dialog_id = full_message_id.get_dialog_id();
Dialog *d = get_dialog_force(dialog_id);
if (d == nullptr) {
@ -6068,15 +6084,27 @@ void MessagesManager::update_message_interaction_info(FullMessageId full_message
return;
}
if (update_message_interaction_info(dialog_id, m, view_count >= 0 ? view_count : m->view_count,
forward_count >= 0 ? forward_count : m->forward_count)) {
on_message_changed(d, m, true, "on_update_message_view_count");
if (view_count < 0) {
view_count = m->view_count;
}
if (forward_count < 0) {
forward_count = m->forward_count;
}
bool is_empty_reply_info = reply_info == nullptr;
MessageReplyInfo new_reply_info(std::move(reply_info), td_->auth_manager_->is_bot());
if (new_reply_info.is_empty() && !is_empty_reply_info) {
has_reply_info = false;
}
if (update_message_interaction_info(dialog_id, m, view_count, forward_count, has_reply_info,
std::move(new_reply_info))) {
on_message_changed(d, m, true, "update_message_interaction_info");
}
}
td_api::object_ptr<td_api::messageInteractionInfo> MessagesManager::get_message_interaction_info_object(
DialogId dialog_id, const Message *m) const {
if (m->view_count == 0 && m->forward_count == 0) {
if (m->view_count == 0 && m->forward_count == 0 && m->reply_info.is_empty()) {
return nullptr;
}
if (m->message_id.is_scheduled() && (m->forward_info == nullptr || is_broadcast_channel(dialog_id))) {
@ -6086,21 +6114,30 @@ td_api::object_ptr<td_api::messageInteractionInfo> MessagesManager::get_message_
return nullptr;
}
return td_api::make_object<td_api::messageInteractionInfo>(m->view_count, m->forward_count);
return td_api::make_object<td_api::messageInteractionInfo>(
m->view_count, m->forward_count, m->reply_info.reply_count,
td_->contacts_manager_->get_user_ids_object(m->reply_info.recent_replier_user_ids,
"get_message_interaction_info_object"));
}
bool MessagesManager::update_message_interaction_info(DialogId dialog_id, Message *m, int32 view_count,
int32 forward_count) {
int32 forward_count, bool has_reply_info,
MessageReplyInfo &&reply_info) {
CHECK(m != nullptr);
if (view_count > m->view_count || forward_count > m->forward_count) {
bool need_update_reply_info = has_reply_info && m->reply_info.need_update_to(reply_info);
if (view_count > m->view_count || forward_count > m->forward_count || need_update_reply_info) {
LOG(DEBUG) << "Update interaction info of " << FullMessageId{dialog_id, m->message_id} << " from " << m->view_count
<< '/' << m->forward_count << " to " << view_count << '/' << forward_count;
<< '/' << m->forward_count << "/" << m->reply_info << " to " << view_count << '/' << forward_count << "/"
<< reply_info;
if (view_count > m->view_count) {
m->view_count = view_count;
}
if (forward_count > m->forward_count) {
m->forward_count = forward_count;
}
if (need_update_reply_info) {
m->reply_info = std::move(reply_info);
}
send_closure(G()->td(), &Td::send_update,
make_tl_object<td_api::updateMessageInteractionInfo>(
dialog_id.get(), m->message_id.get(), get_message_interaction_info_object(dialog_id, m)));
@ -11979,6 +12016,9 @@ MessagesManager::MessageInfo MessagesManager::parse_telegram_api_message(
message_info.view_count = message->views_;
message_info.forward_count = message->forwards_;
}
if (message->flags_ & MESSAGE_FLAG_HAS_REPLY_INFO) {
message_info.reply_info = std::move(message->replies_);
}
if (message->flags_ & MESSAGE_FLAG_HAS_EDIT_DATE) {
message_info.edit_date = message->edit_date_;
}
@ -12155,6 +12195,7 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
LOG(ERROR) << "Wrong forward_count = " << forward_count << " received in " << message_id << " in " << dialog_id;
forward_count = 0;
}
MessageReplyInfo reply_info(std::move(message_info.reply_info), td_->auth_manager_->is_bot());
bool has_forward_info = message_info.forward_header != nullptr;
@ -12187,6 +12228,7 @@ std::pair<DialogId, unique_ptr<MessagesManager::Message>> MessagesManager::creat
message->is_from_scheduled = is_from_scheduled;
message->view_count = view_count;
message->forward_count = forward_count;
message->reply_info = std::move(reply_info);
message->legacy_layer = (is_legacy ? MTPROTO_LAYER : 0);
message->content = std::move(message_info.content);
message->reply_markup = get_reply_markup(std::move(message_info.reply_markup), td_->auth_manager_->is_bot(), false,
@ -20246,6 +20288,7 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
bool can_be_edited = for_event_log ? false : can_edit_message(dialog_id, m, false, td_->auth_manager_->is_bot());
bool can_be_forwarded = for_event_log ? false : can_forward_message(dialog_id, m);
bool can_get_statistics = for_event_log ? false : can_get_message_statistics(dialog_id, m);
bool can_get_replies = for_event_log || is_scheduled ? false : !m->reply_info.is_empty() && m->message_id.is_server();
auto via_bot_user_id = td_->contacts_manager_->get_user_id_object(m->via_bot_user_id, "via_bot_user_id");
auto media_album_id = for_event_log ? static_cast<int64>(0) : m->media_album_id;
auto reply_to_message_id = for_event_log ? static_cast<int64>(0) : m->reply_to_message_id.get();
@ -20256,8 +20299,8 @@ tl_object_ptr<td_api::message> MessagesManager::get_message_object(DialogId dial
return make_tl_object<td_api::message>(
m->message_id.get(), td_->contacts_manager_->get_user_id_object(m->sender_user_id, "sender_user_id"),
dialog_id.get(), std::move(sending_state), std::move(scheduling_state), is_outgoing, can_be_edited,
can_be_forwarded, can_delete_for_self, can_delete_for_all_users, can_get_statistics, m->is_channel_post,
contains_unread_mention, date, edit_date, get_message_forward_info_object(m->forward_info),
can_be_forwarded, can_delete_for_self, can_delete_for_all_users, can_get_statistics, can_get_replies,
m->is_channel_post, contains_unread_mention, date, edit_date, get_message_forward_info_object(m->forward_info),
get_message_interaction_info_object(dialog_id, m), reply_to_message_id, ttl, ttl_expires_in, via_bot_user_id,
m->author_signature, media_album_id, get_restriction_reason_description(m->restriction_reasons),
get_message_content_object(m->content.get(), td_, live_location_date, m->is_content_secret),
@ -20324,6 +20367,23 @@ MessagesManager::Message *MessagesManager::get_message_to_send(
m->from_background = options.from_background;
m->view_count = is_channel_post && !is_scheduled ? 1 : 0;
m->forward_count = 0;
if ([&] {
if (is_scheduled) {
return false;
}
if (dialog_type != DialogType::Channel) {
return false;
}
if (td_->auth_manager_->is_bot()) {
return false;
}
if (is_channel_post) {
return td_->contacts_manager_->get_channel_has_linked_channel(dialog_id.get_channel_id());
}
return !m->reply_to_message_id.is_valid();
}()) {
m->reply_info.reply_count = 0;
}
m->content = std::move(content);
m->forward_info = std::move(forward_info);
m->is_copy = is_copy || forward_info != nullptr;
@ -20770,6 +20830,9 @@ void MessagesManager::add_message_dependencies(Dependencies &dependencies, Dialo
add_dialog_dependencies(dependencies, m->forward_info->from_dialog_id);
}
}
for (auto recent_replier_user_id : m->reply_info.recent_replier_user_ids) {
dependencies.user_ids.insert(recent_replier_user_id);
}
add_message_content_dependencies(dependencies, m->content.get());
}
@ -23383,7 +23446,7 @@ Result<vector<MessageId>> MessagesManager::forward_messages(DialogId to_dialog_i
m->in_game_share = in_game_share;
if (forwarded_message->view_count > 0 && is_broadcast_channel(from_dialog_id)) {
if (update_message_interaction_info(from_dialog_id, forwarded_message, forwarded_message->view_count,
forwarded_message->forward_count + 1)) {
forwarded_message->forward_count + 1, false, {})) {
on_message_changed(from_dialog, forwarded_message, true, "forward_messages");
}
}
@ -30061,7 +30124,8 @@ bool MessagesManager::update_message(Dialog *d, Message *old_message, unique_ptr
update_message_contains_unread_mention(d, old_message, new_message->contains_unread_mention, "update_message")) {
need_send_update = true;
}
if (update_message_interaction_info(dialog_id, old_message, new_message->view_count, new_message->forward_count)) {
if (update_message_interaction_info(dialog_id, old_message, new_message->view_count, new_message->forward_count, true,
std::move(new_message->reply_info))) {
need_send_update = true;
}
if (old_message->restriction_reasons != new_message->restriction_reasons) {
@ -32588,7 +32652,7 @@ void MessagesManager::update_forward_count(DialogId dialog_id, MessageId message
CHECK(d != nullptr);
Message *m = get_message_force(d, message_id, "update_forward_count");
if (m != nullptr && !m->message_id.is_scheduled() && m->message_id.is_server() && m->view_count > 0) {
if (m->forward_count == 0 && update_message_interaction_info(dialog_id, m, m->view_count, 1)) {
if (m->forward_count == 0 && update_message_interaction_info(dialog_id, m, m->view_count, 1, false, {})) {
on_message_changed(d, m, true, "update_forward_count");
}

View File

@ -63,6 +63,7 @@
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include "td/utils/StringBuilder.h"
#include "td/utils/tl_helpers.h"
#include "td/utils/tl_storers.h"
#include <array>
@ -140,6 +141,102 @@ class updateSentMessage : public telegram_api::Update {
}
};
struct MessageReplyInfo {
int32 reply_count = -1;
int32 pts = -1;
vector<UserId> recent_replier_user_ids;
ChannelId channel_id;
bool is_comment = false;
MessageReplyInfo() = default;
MessageReplyInfo(tl_object_ptr<telegram_api::messageReplies> &&reply_info, bool is_bot) {
if (reply_info == nullptr) {
return;
}
if (reply_info->replies_ < 0) {
LOG(ERROR) << "Receive wrong " << to_string(reply_info);
return;
}
reply_count = reply_info->replies_;
pts = reply_info->replies_pts_;
if (!is_bot) {
for (auto &user_id_int : reply_info->recent_repliers_) {
UserId user_id(user_id_int);
if (user_id.is_valid()) {
recent_replier_user_ids.push_back(user_id);
} else {
LOG(ERROR) << "Receive " << user_id << " as a recent replier";
}
}
}
is_comment = reply_info->comments_;
if (is_comment) {
channel_id = ChannelId(reply_info->channel_id_);
if (!channel_id.is_valid()) {
LOG(ERROR) << "Receive invalid " << channel_id;
channel_id = ChannelId();
}
}
}
bool is_empty() const {
return reply_count < 0;
}
bool need_update_to(const MessageReplyInfo &other) const {
if (other.pts < pts) {
return false;
}
return true;
}
template <class StorerT>
void store(StorerT &storer) const {
CHECK(!is_empty());
bool has_recent_replier_user_ids = !recent_replier_user_ids.empty();
bool has_channel_id = channel_id.is_valid();
BEGIN_STORE_FLAGS();
STORE_FLAG(is_comment);
STORE_FLAG(has_recent_replier_user_ids);
STORE_FLAG(has_channel_id);
END_STORE_FLAGS();
td::store(reply_count, storer);
td::store(pts, storer);
if (has_recent_replier_user_ids) {
td::store(recent_replier_user_ids, storer);
}
if (has_channel_id) {
td::store(channel_id, storer);
}
}
template <class ParserT>
void parse(ParserT &parser) {
CHECK(!is_empty());
bool has_recent_replier_user_ids = !recent_replier_user_ids.empty();
bool has_channel_id = channel_id.is_valid();
BEGIN_PARSE_FLAGS();
PARSE_FLAG(is_comment);
PARSE_FLAG(has_recent_replier_user_ids);
PARSE_FLAG(has_channel_id);
END_PARSE_FLAGS();
td::parse(reply_count, parser);
td::parse(pts, parser);
if (has_recent_replier_user_ids) {
td::parse(recent_replier_user_ids, parser);
}
if (has_channel_id) {
td::parse(channel_id, parser);
}
}
};
inline StringBuilder &operator<<(StringBuilder &string_builder, const MessageReplyInfo &reply_info) {
return string_builder << reply_info.reply_count << " replies by " << reply_info.recent_replier_user_ids;
}
class MessagesManager : public Actor {
public:
// static constexpr int32 MESSAGE_FLAG_IS_UNREAD = 1 << 0;
@ -335,7 +432,9 @@ class MessagesManager : public Actor {
void on_update_message_forward_count(FullMessageId full_message_id, int32 forward_count);
void on_update_message_interaction_info(FullMessageId full_message_id, int32 view_count, int32 forward_count);
void on_update_message_interaction_info(FullMessageId full_message_id, int32 view_count, int32 forward_count,
bool has_reply_info,
tl_object_ptr<telegram_api::messageReplies> &&reply_info);
void on_update_live_location_viewed(FullMessageId full_message_id);
@ -909,6 +1008,7 @@ class MessagesManager : public Actor {
UserId via_bot_user_id;
int32 view_count = 0;
int32 forward_count = 0;
tl_object_ptr<telegram_api::messageReplies> reply_info;
int32 flags = 0;
int32 edit_date = 0;
vector<RestrictionReason> restriction_reasons;
@ -1022,6 +1122,8 @@ class MessagesManager : public Actor {
int32 view_count = 0;
int32 forward_count = 0;
MessageReplyInfo reply_info;
int32 legacy_layer = 0;
int32 send_error_code = 0;
@ -1844,12 +1946,14 @@ class MessagesManager : public Actor {
void on_pending_message_views_timeout(DialogId dialog_id);
void update_message_interaction_info(FullMessageId full_message_id, int32 view_count, int32 forward_count);
void update_message_interaction_info(FullMessageId full_message_id, int32 view_count, int32 forward_count,
bool has_reply_info, tl_object_ptr<telegram_api::messageReplies> &&reply_info);
td_api::object_ptr<td_api::messageInteractionInfo> get_message_interaction_info_object(DialogId dialog_id,
const Message *m) const;
bool update_message_interaction_info(DialogId dialog_id, Message *m, int32 view_count, int32 forward_count);
bool update_message_interaction_info(DialogId dialog_id, Message *m, int32 view_count, int32 forward_count,
bool has_reply_info, MessageReplyInfo &&reply_info);
bool update_message_contains_unread_mention(Dialog *d, Message *m, bool contains_unread_mention, const char *source);

View File

@ -506,6 +506,8 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_
CHECK(message->media_ == nullptr);
}
/*
// the users are always min, so no need to check
if (message->replies_ != nullptr) {
for (auto &user_id : message->replies_->recent_repliers_) {
if (!is_acceptable_user(UserId(user_id))) {
@ -513,6 +515,7 @@ bool UpdatesManager::is_acceptable_message(const telegram_api::Message *message_
}
}
}
*/
break;
}