Add MessagesManager::get_chat_ids_object.
This commit is contained in:
parent
cfc46b1893
commit
598ba5422f
@ -29,8 +29,10 @@ DialogFilterInviteLink::DialogFilterInviteLink(
|
||||
}
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::chatFolderInviteLink> DialogFilterInviteLink::get_chat_folder_invite_link_object() const {
|
||||
return td_api::make_object<td_api::chatFolderInviteLink>(invite_link_, title_, DialogId::get_chat_ids(dialog_ids_));
|
||||
td_api::object_ptr<td_api::chatFolderInviteLink> DialogFilterInviteLink::get_chat_folder_invite_link_object(
|
||||
const Td *td) const {
|
||||
return td_api::make_object<td_api::chatFolderInviteLink>(
|
||||
invite_link_, title_, td->messages_manager_->get_chat_ids_object(dialog_ids_, "chatFolderInviteLink"));
|
||||
}
|
||||
|
||||
bool DialogFilterInviteLink::is_valid_invite_link(Slice invite_link) {
|
||||
|
@ -32,7 +32,7 @@ class DialogFilterInviteLink {
|
||||
|
||||
DialogFilterInviteLink(Td *td, telegram_api::object_ptr<telegram_api::exportedChatlistInvite> exported_invite);
|
||||
|
||||
td_api::object_ptr<td_api::chatFolderInviteLink> get_chat_folder_invite_link_object() const;
|
||||
td_api::object_ptr<td_api::chatFolderInviteLink> get_chat_folder_invite_link_object(const Td *td) const;
|
||||
|
||||
bool is_valid() const {
|
||||
return !invite_link_.empty();
|
||||
|
@ -147,7 +147,7 @@ class ExportChatlistInviteQuery final : public Td::ResultHandler {
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for ExportChatlistInviteQuery: " << to_string(ptr);
|
||||
td_->dialog_filter_manager_->on_get_dialog_filter(std::move(ptr->filter_));
|
||||
promise_.set_value(DialogFilterInviteLink(td_, std::move(ptr->invite_)).get_chat_folder_invite_link_object());
|
||||
promise_.set_value(DialogFilterInviteLink(td_, std::move(ptr->invite_)).get_chat_folder_invite_link_object(td_));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
@ -183,7 +183,7 @@ class GetExportedChatlistInvitesQuery final : public Td::ResultHandler {
|
||||
auto result = td_api::make_object<td_api::chatFolderInviteLinks>();
|
||||
for (auto &invite : ptr->invites_) {
|
||||
result->invite_links_.push_back(
|
||||
DialogFilterInviteLink(td_, std::move(invite)).get_chat_folder_invite_link_object());
|
||||
DialogFilterInviteLink(td_, std::move(invite)).get_chat_folder_invite_link_object(td_));
|
||||
}
|
||||
td_->dialog_filter_manager_->set_dialog_filter_has_my_invite_links(dialog_filter_id_,
|
||||
!result->invite_links_.empty());
|
||||
@ -219,7 +219,7 @@ class EditExportedChatlistInviteQuery final : public Td::ResultHandler {
|
||||
|
||||
auto ptr = result_ptr.move_as_ok();
|
||||
LOG(INFO) << "Receive result for EditExportedChatlistInviteQuery: " << to_string(ptr);
|
||||
promise_.set_value(DialogFilterInviteLink(td_, std::move(ptr)).get_chat_folder_invite_link_object());
|
||||
promise_.set_value(DialogFilterInviteLink(td_, std::move(ptr)).get_chat_folder_invite_link_object(td_));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
@ -398,7 +398,7 @@ class GetChatlistUpdatesQuery final : public Td::ResultHandler {
|
||||
td_->contacts_manager_->on_get_users(std::move(ptr->users_), "GetChatlistUpdatesQuery");
|
||||
td_->contacts_manager_->on_get_chats(std::move(ptr->chats_), "GetChatlistUpdatesQuery");
|
||||
auto missing_dialog_ids = td_->messages_manager_->get_peers_dialog_ids(std::move(ptr->missing_peers_), true);
|
||||
promise_.set_value(MessagesManager::get_chats_object(-1, missing_dialog_ids));
|
||||
promise_.set_value(td_->messages_manager_->get_chats_object(-1, missing_dialog_ids, "GetChatlistUpdatesQuery"));
|
||||
}
|
||||
|
||||
void on_error(Status status) final {
|
||||
@ -1704,7 +1704,7 @@ void DialogFilterManager::on_get_leave_dialog_filter_suggestions(
|
||||
|
||||
auto dialog_ids = td_->messages_manager_->get_peers_dialog_ids(std::move(peers));
|
||||
td::remove_if(dialog_ids, [&](DialogId dialog_id) { return !dialog_filter->is_dialog_included(dialog_id); });
|
||||
promise.set_value(MessagesManager::get_chats_object(-1, dialog_ids));
|
||||
promise.set_value(td_->messages_manager_->get_chats_object(-1, dialog_ids, "on_get_leave_dialog_filter_suggestions"));
|
||||
}
|
||||
|
||||
void DialogFilterManager::reorder_dialog_filters(vector<DialogFilterId> dialog_filter_ids,
|
||||
@ -1877,7 +1877,8 @@ void DialogFilterManager::do_get_dialogs_for_dialog_filter_invite_link(
|
||||
return promise.set_error(Status::Error(400, "Chat folder not found"));
|
||||
}
|
||||
|
||||
promise.set_value(MessagesManager::get_chats_object(-1, dialog_filter->get_dialogs_for_invite_link(td_)));
|
||||
promise.set_value(td_->messages_manager_->get_chats_object(-1, dialog_filter->get_dialogs_for_invite_link(td_),
|
||||
"do_get_dialogs_for_dialog_filter_invite_link"));
|
||||
}
|
||||
|
||||
void DialogFilterManager::create_dialog_filter_invite_link(
|
||||
@ -2017,7 +2018,8 @@ void DialogFilterManager::on_get_chatlist_invite(
|
||||
auto missing_dialog_ids = td_->messages_manager_->get_peers_dialog_ids(std::move(missing_peers), true);
|
||||
auto already_dialog_ids = td_->messages_manager_->get_peers_dialog_ids(std::move(already_peers));
|
||||
promise.set_value(td_api::make_object<td_api::chatFolderInviteLinkInfo>(
|
||||
std::move(info), DialogId::get_chat_ids(missing_dialog_ids), DialogId::get_chat_ids(already_dialog_ids)));
|
||||
std::move(info), td_->messages_manager_->get_chat_ids_object(missing_dialog_ids, "chatFolderInviteLinkInfo 1"),
|
||||
td_->messages_manager_->get_chat_ids_object(already_dialog_ids, "chatFolderInviteLinkInfo 1")));
|
||||
}
|
||||
|
||||
void DialogFilterManager::add_dialog_filter_by_invite_link(const string &invite_link, vector<DialogId> dialog_ids,
|
||||
|
@ -181,8 +181,4 @@ vector<DialogId> DialogId::get_dialog_ids(const vector<int64> &chat_ids) {
|
||||
return transform(chat_ids, [](int64 chat_id) { return DialogId(chat_id); });
|
||||
}
|
||||
|
||||
vector<int64> DialogId::get_chat_ids(const vector<DialogId> &dialog_ids) {
|
||||
return transform(dialog_ids, [](DialogId dialog_id) { return dialog_id.get(); });
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -72,8 +72,6 @@ class DialogId {
|
||||
|
||||
static vector<DialogId> get_dialog_ids(const vector<int64> &chat_ids);
|
||||
|
||||
static vector<int64> get_chat_ids(const vector<DialogId> &dialog_ids);
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
storer.store_long(id);
|
||||
|
@ -17241,7 +17241,7 @@ void MessagesManager::get_dialogs_from_list_impl(int64 task_id) {
|
||||
if (!task_promise) {
|
||||
dialog_ids.clear();
|
||||
}
|
||||
return task_promise.set_value(get_chats_object(total_count, dialog_ids));
|
||||
return task_promise.set_value(get_chats_object(total_count, dialog_ids, "get_dialogs_from_list_impl"));
|
||||
}
|
||||
// nor the limit, nor the end of the list were reached; wait for the promise
|
||||
}
|
||||
@ -20606,6 +20606,10 @@ int64 MessagesManager::get_chat_id_object(DialogId dialog_id, const char *source
|
||||
return dialog_id.get();
|
||||
}
|
||||
|
||||
vector<int64> MessagesManager::get_chat_ids_object(const vector<DialogId> &dialog_ids, const char *source) const {
|
||||
return transform(dialog_ids, [this, source](DialogId dialog_id) { return get_chat_id_object(dialog_id, source); });
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::ChatType> MessagesManager::get_chat_type_object(DialogId dialog_id) const {
|
||||
switch (dialog_id.get_type()) {
|
||||
case DialogType::User:
|
||||
@ -20744,15 +20748,17 @@ tl_object_ptr<td_api::chat> MessagesManager::get_chat_object(DialogId dialog_id)
|
||||
return get_chat_object(get_dialog(dialog_id));
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::chats> MessagesManager::get_chats_object(int32 total_count, const vector<DialogId> &dialog_ids) {
|
||||
tl_object_ptr<td_api::chats> MessagesManager::get_chats_object(int32 total_count, const vector<DialogId> &dialog_ids,
|
||||
const char *source) const {
|
||||
if (total_count == -1) {
|
||||
total_count = narrow_cast<int32>(dialog_ids.size());
|
||||
}
|
||||
return td_api::make_object<td_api::chats>(total_count, DialogId::get_chat_ids(dialog_ids));
|
||||
return td_api::make_object<td_api::chats>(total_count, get_chat_ids_object(dialog_ids, source));
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::chats> MessagesManager::get_chats_object(const std::pair<int32, vector<DialogId>> &dialog_ids) {
|
||||
return get_chats_object(dialog_ids.first, dialog_ids.second);
|
||||
tl_object_ptr<td_api::chats> MessagesManager::get_chats_object(const std::pair<int32, vector<DialogId>> &dialog_ids,
|
||||
const char *source) const {
|
||||
return get_chats_object(dialog_ids.first, dialog_ids.second, source);
|
||||
}
|
||||
|
||||
std::pair<bool, int32> MessagesManager::get_dialog_mute_until(DialogId dialog_id, const Dialog *d) const {
|
||||
|
@ -745,11 +745,15 @@ class MessagesManager final : public Actor {
|
||||
|
||||
int64 get_chat_id_object(DialogId dialog_id, const char *source) const;
|
||||
|
||||
vector<int64> get_chat_ids_object(const vector<DialogId> &dialog_ids, const char *source) const;
|
||||
|
||||
tl_object_ptr<td_api::chat> get_chat_object(DialogId dialog_id) const;
|
||||
|
||||
static tl_object_ptr<td_api::chats> get_chats_object(int32 total_count, const vector<DialogId> &dialog_ids);
|
||||
tl_object_ptr<td_api::chats> get_chats_object(int32 total_count, const vector<DialogId> &dialog_ids,
|
||||
const char *source) const;
|
||||
|
||||
static tl_object_ptr<td_api::chats> get_chats_object(const std::pair<int32, vector<DialogId>> &dialog_ids);
|
||||
tl_object_ptr<td_api::chats> get_chats_object(const std::pair<int32, vector<DialogId>> &dialog_ids,
|
||||
const char *source) const;
|
||||
|
||||
tl_object_ptr<td_api::messages> get_dialog_history(DialogId dialog_id, MessageId from_message_id, int32 offset,
|
||||
int32 limit, int left_tries, bool only_local,
|
||||
|
@ -797,7 +797,7 @@ class SearchPublicChatsRequest final : public RequestActor<> {
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(MessagesManager::get_chats_object(-1, dialog_ids_));
|
||||
send_result(td_->messages_manager_->get_chats_object(-1, dialog_ids_, "SearchPublicChatsRequest"));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -817,7 +817,7 @@ class SearchChatsRequest final : public RequestActor<> {
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(MessagesManager::get_chats_object(dialog_ids_));
|
||||
send_result(td_->messages_manager_->get_chats_object(dialog_ids_, "SearchChatsRequest"));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -837,7 +837,7 @@ class SearchChatsOnServerRequest final : public RequestActor<> {
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(MessagesManager::get_chats_object(-1, dialog_ids_));
|
||||
send_result(td_->messages_manager_->get_chats_object(-1, dialog_ids_, "SearchChatsOnServerRequest"));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -859,7 +859,7 @@ class GetGroupsInCommonRequest final : public RequestActor<> {
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(MessagesManager::get_chats_object(dialog_ids_));
|
||||
send_result(td_->messages_manager_->get_chats_object(dialog_ids_, "GetGroupsInCommonRequest"));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -876,7 +876,7 @@ class GetSuitableDiscussionChatsRequest final : public RequestActor<> {
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(MessagesManager::get_chats_object(-1, dialog_ids_));
|
||||
send_result(td_->messages_manager_->get_chats_object(-1, dialog_ids_, "GetSuitableDiscussionChatsRequest"));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -892,7 +892,7 @@ class GetInactiveSupergroupChatsRequest final : public RequestActor<> {
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(MessagesManager::get_chats_object(-1, dialog_ids_));
|
||||
send_result(td_->messages_manager_->get_chats_object(-1, dialog_ids_, "GetInactiveSupergroupChatsRequest"));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -910,7 +910,7 @@ class GetRecentlyOpenedChatsRequest final : public RequestActor<> {
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(MessagesManager::get_chats_object(dialog_ids_));
|
||||
send_result(td_->messages_manager_->get_chats_object(dialog_ids_, "GetRecentlyOpenedChatsRequest"));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -1896,7 +1896,8 @@ class GetChatNotificationSettingsExceptionsRequest final : public RequestActor<>
|
||||
}
|
||||
|
||||
void do_send_result() final {
|
||||
send_result(MessagesManager::get_chats_object(-1, dialog_ids_));
|
||||
send_result(
|
||||
td_->messages_manager_->get_chats_object(-1, dialog_ids_, "GetChatNotificationSettingsExceptionsRequest"));
|
||||
}
|
||||
|
||||
public:
|
||||
@ -4922,15 +4923,8 @@ void Td::on_request(uint64 id, const td_api::clearAutosaveSettingsExceptions &re
|
||||
void Td::on_request(uint64 id, const td_api::getTopChats &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
auto query_promise = PromiseCreator::lambda([promise = std::move(promise)](Result<vector<DialogId>> result) mutable {
|
||||
if (result.is_error()) {
|
||||
promise.set_error(result.move_as_error());
|
||||
} else {
|
||||
promise.set_value(MessagesManager::get_chats_object(-1, result.ok()));
|
||||
}
|
||||
});
|
||||
send_closure(top_dialog_manager_actor_, &TopDialogManager::get_top_dialogs,
|
||||
get_top_dialog_category(request.category_), request.limit_, std::move(query_promise));
|
||||
get_top_dialog_category(request.category_), request.limit_, std::move(promise));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::removeTopChat &request) {
|
||||
|
@ -268,7 +268,8 @@ void TopDialogManager::remove_dialog(TopDialogCategory category, DialogId dialog
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
void TopDialogManager::get_top_dialogs(TopDialogCategory category, int32 limit, Promise<vector<DialogId>> promise) {
|
||||
void TopDialogManager::get_top_dialogs(TopDialogCategory category, int32 limit,
|
||||
Promise<td_api::object_ptr<td_api::chats>> &&promise) {
|
||||
if (category == TopDialogCategory::Size) {
|
||||
return promise.set_error(Status::Error(400, "Top chat category must be non-empty"));
|
||||
}
|
||||
@ -412,7 +413,8 @@ void TopDialogManager::on_load_dialogs(GetTopDialogsQuery &&query, vector<Dialog
|
||||
}
|
||||
}
|
||||
|
||||
query.promise.set_value(std::move(result));
|
||||
query.promise.set_value(
|
||||
td_->messages_manager_->get_chats_object(-1, std::move(result), "TopDialogManager::on_load_dialogs"));
|
||||
}
|
||||
|
||||
void TopDialogManager::do_get_top_peers() {
|
||||
|
@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
#include "td/telegram/TopDialogCategory.h"
|
||||
|
||||
@ -34,7 +35,7 @@ class TopDialogManager final : public Actor {
|
||||
|
||||
void remove_dialog(TopDialogCategory category, DialogId dialog_id, Promise<Unit> &&promise);
|
||||
|
||||
void get_top_dialogs(TopDialogCategory category, int32 limit, Promise<vector<DialogId>> promise);
|
||||
void get_top_dialogs(TopDialogCategory category, int32 limit, Promise<td_api::object_ptr<td_api::chats>> &&promise);
|
||||
|
||||
void update_rating_e_decay();
|
||||
|
||||
@ -66,7 +67,7 @@ class TopDialogManager final : public Actor {
|
||||
struct GetTopDialogsQuery {
|
||||
TopDialogCategory category;
|
||||
size_t limit;
|
||||
Promise<vector<DialogId>> promise;
|
||||
Promise<td_api::object_ptr<td_api::chats>> promise;
|
||||
};
|
||||
vector<GetTopDialogsQuery> pending_get_top_dialogs_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user