diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index d801e0164..ea2966ab4 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -14890,9 +14890,7 @@ void ContactsManager::add_dialog_participants(DialogId dialog_id, const vector &chat_member_status, - Promise &&promise) { - auto status = get_dialog_participant_status(chat_member_status); + DialogParticipantStatus &&status, Promise &&promise) { if (!td_->messages_manager_->have_dialog_force(dialog_id, "set_dialog_participant_status")) { return promise.set_error(Status::Error(400, "Chat not found")); } diff --git a/td/telegram/ContactsManager.h b/td/telegram/ContactsManager.h index 0d86b2aad..5abd303dd 100644 --- a/td/telegram/ContactsManager.h +++ b/td/telegram/ContactsManager.h @@ -527,8 +527,7 @@ class ContactsManager final : public Actor { void add_dialog_participants(DialogId dialog_id, const vector &user_ids, Promise &&promise); void set_dialog_participant_status(DialogId dialog_id, DialogId participant_dialog_id, - const tl_object_ptr &chat_member_status, - Promise &&promise); + DialogParticipantStatus &&status, Promise &&promise); void ban_dialog_participant(DialogId dialog_id, DialogId participant_dialog_id, int32 banned_until_date, bool revoke_messages, Promise &&promise); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index e8c0fadfd..8d315b595 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6221,7 +6221,7 @@ void Td::on_request(uint64 id, const td_api::joinChat &request) { void Td::on_request(uint64 id, const td_api::leaveChat &request) { CREATE_OK_REQUEST_PROMISE(); DialogId dialog_id(request.chat_id_); - td_api::object_ptr new_status = td_api::make_object(); + auto new_status = DialogParticipantStatus::Left(); if (dialog_id.get_type() == DialogType::Channel && messages_manager_->have_dialog_force(dialog_id, "leaveChat")) { auto status = contacts_manager_->get_channel_status(dialog_id.get_channel_id()); if (status.is_creator()) { @@ -6229,12 +6229,11 @@ void Td::on_request(uint64 id, const td_api::leaveChat &request) { return promise.set_value(Unit()); } - new_status = - td_api::make_object(status.get_rank(), status.is_anonymous(), false); + new_status = DialogParticipantStatus::Creator(false, status.is_anonymous(), status.get_rank()); } } - contacts_manager_->set_dialog_participant_status(dialog_id, DialogId(contacts_manager_->get_my_id()), new_status, - std::move(promise)); + contacts_manager_->set_dialog_participant_status(dialog_id, DialogId(contacts_manager_->get_my_id()), + std::move(new_status), std::move(promise)); } void Td::on_request(uint64 id, const td_api::addChatMember &request) { @@ -6255,8 +6254,8 @@ void Td::on_request(uint64 id, const td_api::setChatMemberStatus &request) { CREATE_OK_REQUEST_PROMISE(); TRY_RESULT_PROMISE(promise, participant_dialog_id, get_message_sender_dialog_id(this, request.member_id_, false, false)); - contacts_manager_->set_dialog_participant_status(DialogId(request.chat_id_), participant_dialog_id, request.status_, - std::move(promise)); + contacts_manager_->set_dialog_participant_status(DialogId(request.chat_id_), participant_dialog_id, + get_dialog_participant_status(request.status_), std::move(promise)); } void Td::on_request(uint64 id, const td_api::banChatMember &request) {