tdlight/td/telegram/MessageForwardInfo.h

105 lines
3.1 KiB
C
Raw Normal View History

2024-01-11 16:20:53 +01:00
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
//
// 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
2024-01-11 16:46:10 +01:00
#include "td/telegram/ChannelId.h"
2024-01-11 16:20:53 +01:00
#include "td/telegram/DialogId.h"
2024-01-11 17:11:16 +01:00
#include "td/telegram/MessageFullId.h"
2024-01-11 16:20:53 +01:00
#include "td/telegram/MessageId.h"
#include "td/telegram/MessageOrigin.h"
2024-01-11 16:46:10 +01:00
#include "td/telegram/td_api.h"
#include "td/telegram/telegram_api.h"
#include "td/telegram/UserId.h"
2024-01-11 16:20:53 +01:00
#include "td/utils/common.h"
#include "td/utils/StringBuilder.h"
namespace td {
2024-01-11 16:46:10 +01:00
class Dependencies;
2024-01-11 16:20:53 +01:00
class Td;
struct MessageForwardInfo {
MessageOrigin origin_;
int32 date_ = 0;
DialogId from_dialog_id_;
MessageId from_message_id_;
string psa_type_;
bool is_imported_ = false;
2024-01-11 16:20:53 +01:00
MessageForwardInfo() = default;
MessageForwardInfo(MessageOrigin &&origin, int32 date, DialogId from_dialog_id, MessageId from_message_id,
string &&psa_type, bool is_imported)
: origin_(std::move(origin))
, date_(date)
, from_dialog_id_(from_dialog_id)
, from_message_id_(from_message_id)
, psa_type_(std::move(psa_type))
, is_imported_(is_imported) {
if (from_dialog_id_.is_valid() != from_message_id_.is_valid()) {
from_dialog_id_ = DialogId();
from_message_id_ = MessageId();
}
2024-01-11 16:20:53 +01:00
}
2024-01-11 16:46:10 +01:00
static unique_ptr<MessageForwardInfo> get_message_forward_info(
Td *td, telegram_api::object_ptr<telegram_api::messageFwdHeader> &&forward_header);
td_api::object_ptr<td_api::messageForwardInfo> get_message_forward_info_object(Td *td) const;
td_api::object_ptr<td_api::messageImportInfo> get_message_import_info_object() const;
void add_dependencies(Dependencies &dependencies) const;
void add_min_user_ids(vector<UserId> &user_ids) const;
void add_min_channel_ids(vector<ChannelId> &channel_ids) const;
static bool need_change_warning(const MessageForwardInfo *lhs, const MessageForwardInfo *rhs, MessageId message_id);
int32 get_origin_date() const {
return date_;
}
2024-01-11 17:39:32 +01:00
bool is_imported() const {
return is_imported_;
}
2024-01-11 17:11:16 +01:00
MessageFullId get_origin_message_full_id() const {
return origin_.get_message_full_id();
2024-01-11 17:11:16 +01:00
}
DialogId get_last_dialog_id() const {
return from_dialog_id_;
2024-01-11 17:11:16 +01:00
}
MessageFullId get_last_message_full_id() const {
return {from_dialog_id_, from_message_id_};
2024-01-11 17:11:16 +01:00
}
2024-01-11 16:20:53 +01:00
template <class StorerT>
void store(StorerT &storer) const;
template <class ParserT>
void parse(ParserT &parser);
};
bool operator==(const MessageForwardInfo &lhs, const MessageForwardInfo &rhs);
bool operator!=(const MessageForwardInfo &lhs, const MessageForwardInfo &rhs);
bool operator==(const unique_ptr<MessageForwardInfo> &lhs, const unique_ptr<MessageForwardInfo> &rhs);
bool operator!=(const unique_ptr<MessageForwardInfo> &lhs, const unique_ptr<MessageForwardInfo> &rhs);
2024-01-11 16:20:53 +01:00
StringBuilder &operator<<(StringBuilder &string_builder, const MessageForwardInfo &forward_info);
StringBuilder &operator<<(StringBuilder &string_builder, const unique_ptr<MessageForwardInfo> &forward_info);
2024-01-11 16:20:53 +01:00
} // namespace td