2020-09-07 13:07:40 +02:00
|
|
|
//
|
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020
|
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#include "td/telegram/MessageReplyInfo.h"
|
|
|
|
|
|
|
|
#include "td/utils/logging.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
MessageReplyInfo::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) {
|
2020-09-08 21:08:10 +02:00
|
|
|
for (auto &peer : reply_info->recent_repliers_) {
|
|
|
|
DialogId dialog_id(peer);
|
|
|
|
if (dialog_id.is_valid()) {
|
2020-09-09 01:32:07 +02:00
|
|
|
recent_replier_dialog_ids.push_back(dialog_id);
|
2020-09-07 13:07:40 +02:00
|
|
|
} else {
|
2020-09-08 21:08:10 +02:00
|
|
|
LOG(ERROR) << "Receive " << dialog_id << " as a recent replier";
|
2020-09-07 13:07:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 MessageReplyInfo::need_update_to(const MessageReplyInfo &other) const {
|
|
|
|
if (other.pts < pts) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const MessageReplyInfo &reply_info) {
|
2020-09-09 01:32:07 +02:00
|
|
|
return string_builder << reply_info.reply_count << " replies by " << reply_info.recent_replier_dialog_ids;
|
2020-09-07 13:07:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|