Add get_chat_members_object method.

This commit is contained in:
levlam 2021-01-25 02:07:38 +03:00
parent ef160aa2c0
commit 60673fea78
3 changed files with 18 additions and 16 deletions

View File

@ -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<td_api::chatMembers> DialogParticipants::get_chat_members_object(Td *td) const {
vector<tl_object_ptr<td_api::chatMember>> 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<td_api::chatMembers>(total_count_, std::move(chat_members));
}
tl_object_ptr<telegram_api::ChannelParticipantsFilter>
ChannelParticipantsFilter::get_input_channel_participants_filter() const {
switch (type) {

View File

@ -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<DialogParticipant> &&participants)
: total_count_(total_count), participants_(std::move(participants)) {
}
td_api::object_ptr<td_api::chatMembers> get_chat_members_object(Td *td) const;
};
class ChannelParticipantsFilter {

View File

@ -1976,14 +1976,7 @@ class SearchChatMembersRequest : public RequestActor<> {
}
void do_send_result() override {
// TODO create function get_chat_members_object
vector<tl_object_ptr<td_api::chatMember>> 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<td_api::chatMembers>(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<tl_object_ptr<td_api::chatMember>> 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<td_api::chatMembers>(participants_.total_count_, std::move(result)));
send_result(participants_.get_chat_members_object(td));
}
public: