2019-11-26 17:53:10 +01:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2019-11-26 17:53:10 +01: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/DialogId.h"
|
|
|
|
#include "td/telegram/MessageId.h"
|
2022-12-12 19:43:49 +01:00
|
|
|
#include "td/telegram/telegram_api.h"
|
2019-11-26 17:53:10 +01:00
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2023-08-05 14:31:42 +02:00
|
|
|
#include "td/utils/HashTableUtils.h"
|
2019-11-26 17:53:10 +01:00
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
struct MessageFullId {
|
2019-11-26 17:53:10 +01:00
|
|
|
private:
|
|
|
|
DialogId dialog_id;
|
|
|
|
MessageId message_id;
|
|
|
|
|
|
|
|
public:
|
2023-09-21 18:11:17 +02:00
|
|
|
MessageFullId() : dialog_id(), message_id() {
|
2019-11-26 17:53:10 +01:00
|
|
|
}
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
MessageFullId(DialogId dialog_id, MessageId message_id) : dialog_id(dialog_id), message_id(message_id) {
|
2019-11-26 17:53:10 +01:00
|
|
|
}
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
bool operator==(const MessageFullId &other) const {
|
2019-11-26 17:53:10 +01:00
|
|
|
return dialog_id == other.dialog_id && message_id == other.message_id;
|
|
|
|
}
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
bool operator!=(const MessageFullId &other) const {
|
2019-11-26 17:53:10 +01:00
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
|
|
|
|
DialogId get_dialog_id() const {
|
|
|
|
return dialog_id;
|
|
|
|
}
|
2022-12-12 19:43:49 +01:00
|
|
|
|
2019-11-26 17:53:10 +01:00
|
|
|
MessageId get_message_id() const {
|
|
|
|
return message_id;
|
|
|
|
}
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
static MessageFullId get_message_full_id(const tl_object_ptr<telegram_api::Message> &message_ptr, bool is_scheduled) {
|
2022-12-12 19:43:49 +01:00
|
|
|
return {DialogId::get_message_dialog_id(message_ptr), MessageId::get_message_id(message_ptr, is_scheduled)};
|
|
|
|
}
|
|
|
|
|
2019-11-26 17:53:10 +01:00
|
|
|
template <class StorerT>
|
|
|
|
void store(StorerT &storer) const {
|
|
|
|
dialog_id.store(storer);
|
|
|
|
message_id.store(storer);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class ParserT>
|
|
|
|
void parse(ParserT &parser) {
|
|
|
|
dialog_id.parse(parser);
|
|
|
|
message_id.parse(parser);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
struct MessageFullIdHash {
|
|
|
|
uint32 operator()(MessageFullId message_full_id) const {
|
|
|
|
return combine_hashes(DialogIdHash()(message_full_id.get_dialog_id()),
|
|
|
|
MessageIdHash()(message_full_id.get_message_id()));
|
2019-11-26 17:53:10 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
inline StringBuilder &operator<<(StringBuilder &string_builder, MessageFullId message_full_id) {
|
|
|
|
return string_builder << message_full_id.get_message_id() << " in " << message_full_id.get_dialog_id();
|
2019-11-26 17:53:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|