2020-09-07 13:07:40 +02:00
|
|
|
//
|
2022-01-01 01:35:39 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
|
2020-09-07 13:07:40 +02:00
|
|
|
//
|
|
|
|
// 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)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/telegram/ChannelId.h"
|
2020-09-09 01:32:07 +02:00
|
|
|
#include "td/telegram/DialogId.h"
|
2020-09-15 18:45:45 +02:00
|
|
|
#include "td/telegram/MessageId.h"
|
2021-12-22 18:15:18 +01:00
|
|
|
#include "td/telegram/MinChannel.h"
|
2020-10-12 09:24:30 +02:00
|
|
|
#include "td/telegram/td_api.h"
|
2020-09-07 13:07:40 +02:00
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
2021-12-22 18:15:18 +01:00
|
|
|
#include <utility>
|
|
|
|
|
2020-09-07 13:07:40 +02:00
|
|
|
namespace td {
|
|
|
|
|
2021-12-22 18:15:18 +01:00
|
|
|
class Td;
|
2020-10-08 20:17:24 +02:00
|
|
|
|
2020-09-07 13:07:40 +02:00
|
|
|
struct MessageReplyInfo {
|
2022-11-21 16:35:28 +01:00
|
|
|
int32 reply_count_ = -1;
|
|
|
|
int32 pts_ = -1;
|
|
|
|
vector<DialogId> recent_replier_dialog_ids_; // comments only
|
|
|
|
vector<std::pair<ChannelId, MinChannel>> replier_min_channels_; // comments only
|
|
|
|
ChannelId channel_id_; // comments only
|
|
|
|
MessageId max_message_id_;
|
|
|
|
MessageId last_read_inbox_message_id_;
|
|
|
|
MessageId last_read_outbox_message_id_;
|
|
|
|
bool is_comment_ = false;
|
|
|
|
bool is_dropped_ = false;
|
2020-09-07 13:07:40 +02:00
|
|
|
|
2021-12-20 13:47:03 +01:00
|
|
|
static constexpr size_t MAX_RECENT_REPLIERS = 3;
|
|
|
|
|
2020-09-07 13:07:40 +02:00
|
|
|
MessageReplyInfo() = default;
|
|
|
|
|
2021-12-22 18:15:18 +01:00
|
|
|
MessageReplyInfo(Td *td, tl_object_ptr<telegram_api::messageReplies> &&reply_info, bool is_bot);
|
2020-09-07 13:07:40 +02:00
|
|
|
|
|
|
|
bool is_empty() const {
|
2022-11-21 16:35:28 +01:00
|
|
|
return reply_count_ < 0;
|
2020-09-07 13:07:40 +02:00
|
|
|
}
|
|
|
|
|
2022-10-29 19:18:49 +02:00
|
|
|
bool was_dropped() const {
|
2022-11-21 16:35:28 +01:00
|
|
|
return is_dropped_;
|
2022-10-29 19:18:49 +02:00
|
|
|
}
|
|
|
|
|
2020-09-07 13:07:40 +02:00
|
|
|
bool need_update_to(const MessageReplyInfo &other) const;
|
2020-09-16 15:41:08 +02:00
|
|
|
|
2020-09-18 17:32:59 +02:00
|
|
|
bool update_max_message_ids(MessageId other_max_message_id, MessageId other_last_read_inbox_message_id,
|
|
|
|
MessageId other_last_read_outbox_message_id);
|
2020-09-07 13:07:40 +02:00
|
|
|
|
2020-09-15 18:45:45 +02:00
|
|
|
bool update_max_message_ids(const MessageReplyInfo &other);
|
|
|
|
|
2020-10-31 11:55:53 +01:00
|
|
|
bool add_reply(DialogId replier_dialog_id, MessageId reply_message_id, int diff);
|
2020-09-11 19:12:31 +02:00
|
|
|
|
2021-12-22 18:15:18 +01:00
|
|
|
bool need_reget(const Td *td) const;
|
|
|
|
|
2022-11-21 17:11:38 +01:00
|
|
|
td_api::object_ptr<td_api::messageReplyInfo> get_message_reply_info_object(
|
|
|
|
Td *td, MessageId dialog_last_read_inbox_message_id) const;
|
2020-10-08 20:17:24 +02:00
|
|
|
|
2020-09-07 13:07:40 +02:00
|
|
|
template <class StorerT>
|
2021-12-22 18:29:54 +01:00
|
|
|
void store(StorerT &storer) const;
|
2020-09-07 13:07:40 +02:00
|
|
|
|
|
|
|
template <class ParserT>
|
2021-12-22 18:29:54 +01:00
|
|
|
void parse(ParserT &parser);
|
2020-09-07 13:07:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const MessageReplyInfo &reply_info);
|
|
|
|
|
2021-12-27 12:03:50 +01:00
|
|
|
} // namespace td
|