From 60673fea785b67528c04cb2a3a7fc3d6fb47c208 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 25 Jan 2021 02:07:38 +0300 Subject: [PATCH] Add get_chat_members_object method. --- td/telegram/DialogParticipant.cpp | 12 ++++++++++++ td/telegram/DialogParticipant.h | 4 ++++ td/telegram/Td.cpp | 18 ++---------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/td/telegram/DialogParticipant.cpp b/td/telegram/DialogParticipant.cpp index 5c7abce7c..d4700b0d2 100644 --- a/td/telegram/DialogParticipant.cpp +++ b/td/telegram/DialogParticipant.cpp @@ -6,8 +6,10 @@ // #include "td/telegram/DialogParticipant.h" +#include "td/telegram/ContactsManager.h" #include "td/telegram/Global.h" #include "td/telegram/misc.h" +#include "td/telegram/Td.h" #include "td/utils/common.h" #include "td/utils/logging.h" @@ -705,6 +707,16 @@ StringBuilder &operator<<(StringBuilder &string_builder, const DialogParticipant << ']'; } +td_api::object_ptr DialogParticipants::get_chat_members_object(Td *td) const { + vector> chat_members; + chat_members.reserve(participants_.size()); + for (auto &participant : participants_) { + chat_members.push_back(td->contacts_manager_->get_chat_member_object(participant)); + } + + return td_api::make_object(total_count_, std::move(chat_members)); +} + tl_object_ptr ChannelParticipantsFilter::get_input_channel_participants_filter() const { switch (type) { diff --git a/td/telegram/DialogParticipant.h b/td/telegram/DialogParticipant.h index 30960d340..5f376c241 100644 --- a/td/telegram/DialogParticipant.h +++ b/td/telegram/DialogParticipant.h @@ -17,6 +17,8 @@ namespace td { +class Td; + class RestrictedRights { static constexpr uint32 CAN_SEND_MESSAGES = 1 << 16; static constexpr uint32 CAN_SEND_MEDIA = 1 << 17; @@ -417,6 +419,8 @@ struct DialogParticipants { DialogParticipants(int32 total_count, vector &&participants) : total_count_(total_count), participants_(std::move(participants)) { } + + td_api::object_ptr get_chat_members_object(Td *td) const; }; class ChannelParticipantsFilter { diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 15c6e8dc5..a571cca68 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -1976,14 +1976,7 @@ class SearchChatMembersRequest : public RequestActor<> { } void do_send_result() override { - // TODO create function get_chat_members_object - vector> result; - result.reserve(participants_.participants_.size()); - for (auto participant : participants_.participants_) { - result.push_back(td->contacts_manager_->get_chat_member_object(participant)); - } - - send_result(make_tl_object(participants_.total_count_, std::move(result))); + send_result(participants_.get_chat_members_object(td)); } public: @@ -2293,14 +2286,7 @@ class GetSupergroupMembersRequest : public RequestActor<> { } void do_send_result() override { - // TODO create function get_chat_members_object - vector> result; - result.reserve(participants_.participants_.size()); - for (auto participant : participants_.participants_) { - result.push_back(td->contacts_manager_->get_chat_member_object(participant)); - } - - send_result(make_tl_object(participants_.total_count_, std::move(result))); + send_result(participants_.get_chat_members_object(td)); } public: