Skip to content

Commit

Permalink
Pass chat member status as DialogParticipantStatus.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Nov 15, 2021
1 parent 76e1466 commit 922fd9b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 1 addition & 3 deletions td/telegram/ContactsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14890,9 +14890,7 @@ void ContactsManager::add_dialog_participants(DialogId dialog_id, const vector<U
}

void ContactsManager::set_dialog_participant_status(DialogId dialog_id, DialogId participant_dialog_id,
const tl_object_ptr<td_api::ChatMemberStatus> &chat_member_status,
Promise<Unit> &&promise) {
auto status = get_dialog_participant_status(chat_member_status);
DialogParticipantStatus &&status, Promise<Unit> &&promise) {
if (!td_->messages_manager_->have_dialog_force(dialog_id, "set_dialog_participant_status")) {
return promise.set_error(Status::Error(400, "Chat not found"));
}
Expand Down
3 changes: 1 addition & 2 deletions td/telegram/ContactsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,7 @@ class ContactsManager final : public Actor {
void add_dialog_participants(DialogId dialog_id, const vector<UserId> &user_ids, Promise<Unit> &&promise);

void set_dialog_participant_status(DialogId dialog_id, DialogId participant_dialog_id,
const tl_object_ptr<td_api::ChatMemberStatus> &chat_member_status,
Promise<Unit> &&promise);
DialogParticipantStatus &&status, Promise<Unit> &&promise);

void ban_dialog_participant(DialogId dialog_id, DialogId participant_dialog_id, int32 banned_until_date,
bool revoke_messages, Promise<Unit> &&promise);
Expand Down
13 changes: 6 additions & 7 deletions td/telegram/Td.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6221,20 +6221,19 @@ 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<td_api::ChatMemberStatus> new_status = td_api::make_object<td_api::chatMemberStatusLeft>();
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()) {
if (!status.is_member()) {
return promise.set_value(Unit());
}

new_status =
td_api::make_object<td_api::chatMemberStatusCreator>(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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 922fd9b

Please sign in to comment.