Add Dependencies.h.
GitOrigin-RevId: 791b4dc804a8c0b734b027ff348b16bbfceede5c
This commit is contained in:
parent
144816b469
commit
4597689060
@ -456,6 +456,7 @@ set(TDLIB_SOURCE
|
|||||||
td/telegram/Contact.h
|
td/telegram/Contact.h
|
||||||
td/telegram/ContactsManager.h
|
td/telegram/ContactsManager.h
|
||||||
td/telegram/DelayDispatcher.h
|
td/telegram/DelayDispatcher.h
|
||||||
|
td/telegram/Dependencies.h
|
||||||
td/telegram/DeviceTokenManager.h
|
td/telegram/DeviceTokenManager.h
|
||||||
td/telegram/DhCache.h
|
td/telegram/DhCache.h
|
||||||
td/telegram/DhConfig.h
|
td/telegram/DhConfig.h
|
||||||
|
29
td/telegram/Dependencies.h
Normal file
29
td/telegram/Dependencies.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
//
|
||||||
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
|
||||||
|
//
|
||||||
|
// 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"
|
||||||
|
#include "td/telegram/ChatId.h"
|
||||||
|
#include "td/telegram/DialogId.h"
|
||||||
|
#include "td/telegram/SecretChatId.h"
|
||||||
|
#include "td/telegram/UserId.h"
|
||||||
|
#include "td/telegram/WebPageId.h"
|
||||||
|
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
|
namespace td {
|
||||||
|
|
||||||
|
struct Dependencies {
|
||||||
|
std::unordered_set<UserId, UserIdHash> user_ids;
|
||||||
|
std::unordered_set<ChatId, ChatIdHash> chat_ids;
|
||||||
|
std::unordered_set<ChannelId, ChannelIdHash> channel_ids;
|
||||||
|
std::unordered_set<SecretChatId, SecretChatIdHash> secret_chat_ids;
|
||||||
|
std::unordered_set<DialogId, DialogIdHash> dialog_ids;
|
||||||
|
std::unordered_set<WebPageId, WebPageIdHash> web_page_ids;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace td
|
@ -2196,4 +2196,12 @@ Status fix_formatted_text(string &text, vector<MessageEntity> &entities, bool al
|
|||||||
return Status::OK();
|
return Status::OK();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText &text) {
|
||||||
|
for (auto &entity : text.entities) {
|
||||||
|
if (entity.user_id.is_valid()) {
|
||||||
|
dependencies.user_ids.insert(entity.user_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "td/telegram/Dependencies.h"
|
||||||
#include "td/telegram/UserId.h"
|
#include "td/telegram/UserId.h"
|
||||||
|
|
||||||
#include "td/utils/common.h"
|
#include "td/utils/common.h"
|
||||||
@ -144,4 +145,6 @@ vector<MessageEntity> get_message_entities(vector<tl_object_ptr<secret_api::Mess
|
|||||||
Status fix_formatted_text(string &text, vector<MessageEntity> &entities, bool allow_empty, bool skip_new_entities,
|
Status fix_formatted_text(string &text, vector<MessageEntity> &entities, bool allow_empty, bool skip_new_entities,
|
||||||
bool skip_bot_commands, bool for_draft) TD_WARN_UNUSED_RESULT;
|
bool skip_bot_commands, bool for_draft) TD_WARN_UNUSED_RESULT;
|
||||||
|
|
||||||
|
void add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText &text);
|
||||||
|
|
||||||
} // namespace td
|
} // namespace td
|
||||||
|
@ -16681,14 +16681,6 @@ bool MessagesManager::is_message_auto_read(DialogId dialog_id, bool is_outgoing)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesManager::add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText &text) {
|
|
||||||
for (auto &entity : text.entities) {
|
|
||||||
if (entity.user_id.is_valid()) {
|
|
||||||
dependencies.user_ids.insert(entity.user_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MessagesManager::add_message_dependencies(Dependencies &dependencies, DialogId dialog_id, const Message *m) {
|
void MessagesManager::add_message_dependencies(Dependencies &dependencies, DialogId dialog_id, const Message *m) {
|
||||||
dependencies.user_ids.insert(m->sender_user_id);
|
dependencies.user_ids.insert(m->sender_user_id);
|
||||||
dependencies.user_ids.insert(m->via_bot_user_id);
|
dependencies.user_ids.insert(m->via_bot_user_id);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "td/telegram/ChannelId.h"
|
#include "td/telegram/ChannelId.h"
|
||||||
#include "td/telegram/ChatId.h"
|
#include "td/telegram/ChatId.h"
|
||||||
#include "td/telegram/Contact.h"
|
#include "td/telegram/Contact.h"
|
||||||
|
#include "td/telegram/Dependencies.h"
|
||||||
#include "td/telegram/DialogId.h"
|
#include "td/telegram/DialogId.h"
|
||||||
#include "td/telegram/DialogParticipant.h"
|
#include "td/telegram/DialogParticipant.h"
|
||||||
#include "td/telegram/DocumentsManager.h"
|
#include "td/telegram/DocumentsManager.h"
|
||||||
@ -855,16 +856,6 @@ class dummyUpdate : public telegram_api::Update {
|
|||||||
void store(TlStorerToString &s, const char *field_name) const override;
|
void store(TlStorerToString &s, const char *field_name) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Dependencies {
|
|
||||||
public:
|
|
||||||
std::unordered_set<UserId, UserIdHash> user_ids;
|
|
||||||
std::unordered_set<ChatId, ChatIdHash> chat_ids;
|
|
||||||
std::unordered_set<ChannelId, ChannelIdHash> channel_ids;
|
|
||||||
std::unordered_set<SecretChatId, SecretChatIdHash> secret_chat_ids;
|
|
||||||
std::unordered_set<DialogId, DialogIdHash> dialog_ids;
|
|
||||||
std::unordered_set<WebPageId, WebPageIdHash> web_page_ids;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CallsDbState {
|
struct CallsDbState {
|
||||||
std::array<MessageId, 2> first_calls_database_message_id_by_index;
|
std::array<MessageId, 2> first_calls_database_message_id_by_index;
|
||||||
std::array<int32, 2> message_count_by_index;
|
std::array<int32, 2> message_count_by_index;
|
||||||
@ -2747,8 +2738,6 @@ class MessagesManager : public Actor {
|
|||||||
|
|
||||||
static void dump_debug_message_op(const Dialog *d, int priority = 0);
|
static void dump_debug_message_op(const Dialog *d, int priority = 0);
|
||||||
|
|
||||||
static void add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText &text);
|
|
||||||
|
|
||||||
static void add_message_dependencies(Dependencies &dependencies, DialogId dialog_id, const Message *m);
|
static void add_message_dependencies(Dependencies &dependencies, DialogId dialog_id, const Message *m);
|
||||||
|
|
||||||
static void add_dialog_dependencies(Dependencies &dependencies, DialogId dialog_id);
|
static void add_dialog_dependencies(Dependencies &dependencies, DialogId dialog_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user