mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Support anonymous group admins.
This commit is contained in:
@@ -564,6 +564,12 @@ UserData *ParticipantsAdditionalData::applyCreator(
|
||||
const MTPDchannelParticipantCreator &data) {
|
||||
if (const auto user = applyRegular(data.vuser_id())) {
|
||||
_creator = user;
|
||||
_adminRights[user] = data.vadmin_rights();
|
||||
if (user->isSelf()) {
|
||||
_adminCanEdit.emplace(user);
|
||||
} else {
|
||||
_adminCanEdit.erase(user);
|
||||
}
|
||||
if (const auto rank = data.vrank()) {
|
||||
_adminRanks[user] = qs(*rank);
|
||||
} else {
|
||||
@@ -1459,11 +1465,7 @@ base::unique_qptr<Ui::PopupMenu> ParticipantsBoxController::rowContextMenu(
|
||||
|
||||
void ParticipantsBoxController::showAdmin(not_null<UserData*> user) {
|
||||
const auto adminRights = _additional.adminRights(user);
|
||||
const auto currentRights = _additional.isCreator(user)
|
||||
? MTPChatAdminRights(MTP_chatAdminRights(
|
||||
MTP_flags(~MTPDchatAdminRights::Flag::f_add_admins
|
||||
| MTPDchatAdminRights::Flag::f_add_admins)))
|
||||
: adminRights
|
||||
const auto currentRights = adminRights
|
||||
? *adminRights
|
||||
: MTPChatAdminRights(MTP_chatAdminRights(MTP_flags(0)));
|
||||
auto box = Box<EditAdminBox>(
|
||||
@@ -1504,7 +1506,7 @@ void ParticipantsBoxController::editAdminDone(
|
||||
_additional.applyParticipant(MTP_channelParticipantCreator(
|
||||
MTP_flags(rank.isEmpty() ? Flag(0) : Flag::f_rank),
|
||||
MTP_int(user->bareId()),
|
||||
MTP_chatAdminRights(MTP_flags(0)), // #TODO anonymous
|
||||
rights,
|
||||
MTP_string(rank)));
|
||||
} else if (rights.c_chatAdminRights().vflags().v == 0) {
|
||||
_additional.applyParticipant(MTP_channelParticipant(
|
||||
@@ -1784,6 +1786,7 @@ std::unique_ptr<PeerListRow> ParticipantsBoxController::createRow(
|
||||
auto row = std::make_unique<PeerListRowWithLink>(user);
|
||||
refreshCustomStatus(row.get());
|
||||
if (_role == Role::Admins
|
||||
&& !_additional.isCreator(user)
|
||||
&& _additional.adminRights(user).has_value()
|
||||
&& _additional.canEditAdmin(user)) {
|
||||
row->setActionLink(tr::lng_profile_kick(tr::now));
|
||||
|
Reference in New Issue
Block a user