2022-02-05 21:28:43 +01:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2022-02-05 21:28:43 +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
|
|
|
|
|
2022-10-24 16:36:31 +02:00
|
|
|
#include "td/telegram/ChannelId.h"
|
|
|
|
#include "td/telegram/ChatId.h"
|
2022-02-05 21:28:43 +01:00
|
|
|
#include "td/telegram/DialogId.h"
|
|
|
|
#include "td/telegram/FolderId.h"
|
|
|
|
#include "td/telegram/MessageContentType.h"
|
2023-09-21 18:11:17 +02:00
|
|
|
#include "td/telegram/MessageFullId.h"
|
2022-02-05 21:28:43 +01:00
|
|
|
#include "td/telegram/PollId.h"
|
2023-05-30 13:41:36 +02:00
|
|
|
#include "td/telegram/StoryFullId.h"
|
2022-12-13 12:16:49 +01:00
|
|
|
#include "td/telegram/UserId.h"
|
2022-02-05 21:28:43 +01:00
|
|
|
|
|
|
|
#include "td/utils/common.h"
|
2022-11-23 17:37:32 +01:00
|
|
|
#include "td/utils/HashTableUtils.h"
|
2022-02-05 22:16:16 +01:00
|
|
|
|
2022-02-05 21:28:43 +01:00
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class ChainId {
|
|
|
|
uint64 id = 0;
|
|
|
|
|
|
|
|
public:
|
2022-10-24 16:36:31 +02:00
|
|
|
ChainId(ChannelId channel_id) : ChainId(DialogId(channel_id)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ChainId(ChatId chat_id) : ChainId(DialogId(chat_id)) {
|
|
|
|
}
|
|
|
|
|
2022-02-08 15:30:06 +01:00
|
|
|
ChainId(DialogId dialog_id, MessageContentType message_content_type)
|
2022-02-05 21:28:43 +01:00
|
|
|
: id((static_cast<uint64>(dialog_id.get()) << 10) + get_message_content_chain_id(message_content_type)) {
|
|
|
|
}
|
|
|
|
|
2022-02-08 15:30:06 +01:00
|
|
|
ChainId(DialogId dialog_id) : id((static_cast<uint64>(dialog_id.get()) << 10) + 10) {
|
|
|
|
}
|
|
|
|
|
2023-09-21 18:11:17 +02:00
|
|
|
ChainId(MessageFullId message_full_id) : ChainId(message_full_id.get_dialog_id()) {
|
|
|
|
id += static_cast<uint64>(message_full_id.get_message_id().get()) << 10;
|
2022-02-16 16:36:55 +01:00
|
|
|
}
|
|
|
|
|
2022-02-05 21:28:43 +01:00
|
|
|
ChainId(FolderId folder_id) : id((static_cast<uint64>(folder_id.get() + (1 << 30)) << 10)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ChainId(PollId poll_id) : id(static_cast<uint64>(poll_id.get())) {
|
|
|
|
}
|
|
|
|
|
2022-11-23 17:37:32 +01:00
|
|
|
ChainId(const string &str) : id(Hash<string>()(str)) {
|
2022-02-05 22:16:16 +01:00
|
|
|
}
|
|
|
|
|
2022-12-13 12:16:49 +01:00
|
|
|
ChainId(UserId user_id) : ChainId(DialogId(user_id)) {
|
|
|
|
}
|
|
|
|
|
2023-05-30 13:41:36 +02:00
|
|
|
ChainId(StoryFullId story_full_id) : ChainId(story_full_id.get_dialog_id()) {
|
|
|
|
id += static_cast<uint64>(story_full_id.get_story_id().get()) << 10;
|
|
|
|
}
|
|
|
|
|
2022-02-05 21:28:43 +01:00
|
|
|
uint64 get() const {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|