From 80d8e9336f974eaa7dbc6fa641c514501784a0a0 Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 19 Oct 2023 18:11:15 +0300 Subject: [PATCH] Reuse generic DialogParticipantStatus::Administrator constructor. --- td/telegram/DialogParticipant.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/td/telegram/DialogParticipant.cpp b/td/telegram/DialogParticipant.cpp index c7b876373..bcdfb3b07 100644 --- a/td/telegram/DialogParticipant.cpp +++ b/td/telegram/DialogParticipant.cpp @@ -478,24 +478,21 @@ DialogParticipantStatus::DialogParticipantStatus(bool can_be_edited, tl_object_ptr &&admin_rights, string rank, ChannelType channel_type) { CHECK(admin_rights != nullptr); - uint64 flags = AdministratorRights(admin_rights, channel_type).flags_ | AdministratorRights::CAN_MANAGE_DIALOG; - if (can_be_edited) { - flags |= CAN_BE_EDITED; - } - flags |= (RestrictedRights::ALL_RESTRICTED_RIGHTS & ~RestrictedRights::ALL_ADMIN_PERMISSION_RIGHTS) | IS_MEMBER; - *this = DialogParticipantStatus(Type::Administrator, flags, 0, std::move(rank)); + *this = Administrator(AdministratorRights(admin_rights, channel_type), std::move(rank), can_be_edited); } DialogParticipantStatus::DialogParticipantStatus(bool is_member, tl_object_ptr &&banned_rights) { CHECK(banned_rights != nullptr); if (banned_rights->view_messages_) { - *this = DialogParticipantStatus::Banned(banned_rights->until_date_); + *this = Banned(banned_rights->until_date_); return; } auto until_date = fix_until_date(banned_rights->until_date_); banned_rights->until_date_ = std::numeric_limits::max(); + + // manually create Restricted status, because the user can be restricted, but with yet unknown restrictions uint64 flags = RestrictedRights(banned_rights).flags_ | (static_cast(is_member) * IS_MEMBER); *this = DialogParticipantStatus(Type::Restricted, flags, until_date, string()); }