From 2c38e261d2fb52eaca622d4b7c7886c1080e704f Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 18 Mar 2022 18:27:10 +0300 Subject: [PATCH] Reuse RestrictedRights::get_chat_banned_rights. --- td/telegram/DialogParticipant.cpp | 47 ++++--------------------------- 1 file changed, 5 insertions(+), 42 deletions(-) diff --git a/td/telegram/DialogParticipant.cpp b/td/telegram/DialogParticipant.cpp index ad623ab3b..7a8818c56 100644 --- a/td/telegram/DialogParticipant.cpp +++ b/td/telegram/DialogParticipant.cpp @@ -140,7 +140,7 @@ RestrictedRights::RestrictedRights(bool can_send_messages, bool can_send_media, (static_cast(can_pin_messages) * CAN_PIN_MESSAGES); } -tl_object_ptr RestrictedRights::get_chat_permissions_object() const { +td_api::object_ptr RestrictedRights::get_chat_permissions_object() const { return td_api::make_object( can_send_messages(), can_send_media(), can_send_polls(), can_send_stickers() || can_send_animations() || can_send_games() || can_use_inline_bots(), @@ -350,49 +350,12 @@ tl_object_ptr DialogParticipantStatus::get_chat_a } tl_object_ptr DialogParticipantStatus::get_chat_banned_rights() const { - int32 flags = 0; + auto result = get_restricted_rights().get_chat_banned_rights(); if (type_ == Type::Banned) { - flags |= telegram_api::chatBannedRights::VIEW_MESSAGES_MASK; + result->flags_ |= telegram_api::chatBannedRights::VIEW_MESSAGES_MASK; } - if (!can_send_messages()) { - flags |= telegram_api::chatBannedRights::SEND_MESSAGES_MASK; - } - if (!can_send_media()) { - flags |= telegram_api::chatBannedRights::SEND_MEDIA_MASK; - } - if (!can_send_stickers()) { - flags |= telegram_api::chatBannedRights::SEND_STICKERS_MASK; - } - if (!can_send_animations()) { - flags |= telegram_api::chatBannedRights::SEND_GIFS_MASK; - } - if (!can_send_games()) { - flags |= telegram_api::chatBannedRights::SEND_GAMES_MASK; - } - if (!can_use_inline_bots()) { - flags |= telegram_api::chatBannedRights::SEND_INLINE_MASK; - } - if (!can_add_web_page_previews()) { - flags |= telegram_api::chatBannedRights::EMBED_LINKS_MASK; - } - if (!can_send_polls()) { - flags |= telegram_api::chatBannedRights::SEND_POLLS_MASK; - } - if ((flags_ & CAN_CHANGE_INFO_AND_SETTINGS_BANNED) == 0) { - flags |= telegram_api::chatBannedRights::CHANGE_INFO_MASK; - } - if ((flags_ & CAN_INVITE_USERS_BANNED) == 0) { - flags |= telegram_api::chatBannedRights::INVITE_USERS_MASK; - } - if ((flags_ & CAN_PIN_MESSAGES_BANNED) == 0) { - flags |= telegram_api::chatBannedRights::PIN_MESSAGES_MASK; - } - - LOG(INFO) << "Create chat banned rights " << flags << " until " << until_date_; - return make_tl_object( - flags, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, - false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, false /*ignored*/, - false /*ignored*/, until_date_); + result->until_date_ = until_date_; + return result; } DialogParticipantStatus DialogParticipantStatus::apply_restrictions(RestrictedRights default_restrictions,