diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index b9bcb2d1bf..beeadffcff 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -700,6 +700,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_profile_join_group" = "Join Group"; "lng_profile_delete_and_exit" = "Leave"; "lng_profile_kick" = "Remove"; +"lng_profile_delete_removed" = "Delete"; "lng_profile_sure_kick" = "Remove {user} from the group?"; "lng_profile_sure_kick_channel" = "Remove {user} from the channel?"; "lng_profile_sure_remove_admin" = "Remove {user} from admins?"; @@ -827,6 +828,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_channel_admin_status_promoted_by" = "Promoted by {user}"; "lng_channel_admin_status_not_admin" = "Not administrator"; "lng_channel_banned_status_restricted_by" = "Restricted by {user}"; +"lng_channel_banned_status_removed_by" = "Removed by {user}"; "lng_channel_removed_list_about" = "Users removed from the channel by admins cannot rejoin it via invite links."; "lng_group_removed_list_about" = "Users removed from the group by admins cannot rejoin it via invite links."; @@ -1229,6 +1231,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_context_edit_permissions" = "Edit permissions"; "lng_context_restrict_user" = "Restrict user"; "lng_context_remove_from_group" = "Remove from group"; +"lng_context_add_to_group" = "Add to group"; "lng_context_copy_link" = "Copy Link"; "lng_context_copy_post_link" = "Copy Post Link"; diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 16c757c88f..0a650cc97f 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1759,11 +1759,15 @@ void ApiWrap::saveDefaultRestrictions( if (error.type() == qstr("CHAT_NOT_MODIFIED")) { if (const auto chat = peer->asChat()) { chat->setDefaultRestrictions(rights); - if (callback) { - callback(true); - } - return; + } else if (const auto channel = peer->asChannel()) { + channel->setDefaultRestrictions(rights); + } else { + Unexpected("Peer in ApiWrap::saveDefaultRestrictions."); } + if (callback) { + callback(true); + } + return; } if (callback) { callback(false); diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index 560575b25d..4917177544 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1352,6 +1352,20 @@ base::unique_qptr ParticipantsBoxController::rowContextMenu( result->addAction( lang(lng_context_view_profile), crl::guard(this, [=] { _navigation->showPeerInfo(user); })); + if (_role == Role::Kicked) { + if (_peer->isMegagroup() + && _additional.canRestrictUser(user)) { + if (channel->canAddMembers()) { + result->addAction( + lang(lng_context_add_to_group), + crl::guard(this, [=] { unkickMember(user); })); + } + result->addAction( + lang(lng_profile_delete_removed), + crl::guard(this, [=] { removeKickedWithRow(user); })); + } + return result; + } if (_additional.canAddOrEditAdmin(user)) { const auto isAdmin = _additional.isCreator(user) || _additional.adminRights(user).has_value(); @@ -1369,11 +1383,13 @@ base::unique_qptr ParticipantsBoxController::rowContextMenu( lang(lng_context_restrict_user), crl::guard(this, [=] { showRestricted(user); })); } - result->addAction( - lang(isGroup - ? lng_context_remove_from_group - : lng_profile_kick), - crl::guard(this, [=] { kickMember(user); })); + if (!_additional.isKicked(user)) { + result->addAction( + lang(isGroup + ? lng_context_remove_from_group + : lng_profile_kick), + crl::guard(this, [=] { kickMember(user); })); + } } return result; } @@ -1528,6 +1544,15 @@ void ParticipantsBoxController::kickMember(not_null user) { LayerOption::KeepOther); } +void ParticipantsBoxController::unkickMember(not_null user) { + _editBox = nullptr; + if (const auto row = delegate()->peerListFindRow(user->id)) { + delegate()->peerListRemoveRow(row); + delegate()->peerListRefreshRows(); + } + _peer->session().api().addChatParticipants(_peer, { 1, user }); +} + void ParticipantsBoxController::kickMemberSure(not_null user) { _editBox = nullptr; @@ -1579,15 +1604,26 @@ void ParticipantsBoxController::removeAdminSure(not_null user) { } } +void ParticipantsBoxController::removeKickedWithRow( + not_null user) { + if (const auto row = delegate()->peerListFindRow(user->id)) { + removeKicked(row, user); + } else { + removeKicked(user); + } +} +void ParticipantsBoxController::removeKicked(not_null user) { + if (const auto channel = _peer->asChannel()) { + channel->session().api().unblockParticipant(channel, user); + } +} + void ParticipantsBoxController::removeKicked( not_null row, not_null user) { delegate()->peerListRemoveRow(row); delegate()->peerListRefreshRows(); - - if (const auto channel = _peer->asChannel()) { - channel->session().api().unblockParticipant(channel, user); - } + removeKicked(user); } bool ParticipantsBoxController::appendRow(not_null user) { @@ -1651,7 +1687,7 @@ std::unique_ptr ParticipantsBoxController::createRow( && _additional.canEditAdmin(user)) { row->setActionLink(lang(lng_profile_kick)); } else if (_role == Role::Kicked) { - row->setActionLink(lang(lng_blocked_list_unblock)); + row->setActionLink(lang(lng_profile_delete_removed)); } else if (_role == Role::Members) { if ((chat ? chat->canBanMembers() : channel->canBanMembers()) && !_additional.isCreator(user) @@ -1704,7 +1740,9 @@ void ParticipantsBoxController::refreshCustomStatus( } } else if (_role == Role::Kicked || _role == Role::Restricted) { const auto by = _additional.restrictedBy(user); - row->setCustomStatus(lng_channel_banned_status_restricted_by( + row->setCustomStatus((_role == Role::Kicked + ? lng_channel_banned_status_removed_by + : lng_channel_banned_status_restricted_by)( lt_user, by ? App::peerName(by) : "Unknown")); } diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.h b/Telegram/SourceFiles/boxes/peers/edit_participants_box.h index 3f1d520525..3e5dfb3f44 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.h @@ -209,8 +209,11 @@ private: not_null user, const MTPChatBannedRights &rights); void removeKicked(not_null row, not_null user); + void removeKickedWithRow(not_null user); + void removeKicked(not_null user); void kickMember(not_null user); void kickMemberSure(not_null user); + void unkickMember(not_null user); void removeAdmin(not_null user); void removeAdminSure(not_null user); bool appendRow(not_null user);