diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 1d8fe5099..1c2d2722d 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -4226,6 +4226,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_rights_edit_admin_rank_about" = "A title that members will see instead of '{title}'."; "lng_rights_about_add_admins_yes" = "This admin will be able to add new admins with equal or fewer rights."; "lng_rights_about_add_admins_no" = "This admin will not be able to add new admins."; +"lng_rights_about_by" = "This admin promoted by {user} at {date}."; "lng_rights_about_admin_cant_edit" = "You can't edit the rights of this admin."; "lng_rights_about_restriction_cant_edit" = "You cannot change the restrictions for this user."; diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index d8dd581a3..0aba9b6a5 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -217,7 +217,9 @@ void ShowAddParticipantsError( channel, user, ChatAdminRightsInfo(), - QString()); + QString(), + 0, + nullptr); box->setSaveCallback(saveCallback); *weak = box.data(); show->showBox(std::move(box)); diff --git a/Telegram/SourceFiles/boxes/peers/add_bot_to_chat_box.cpp b/Telegram/SourceFiles/boxes/peers/add_bot_to_chat_box.cpp index 8c8db3960..9991cff6f 100644 --- a/Telegram/SourceFiles/boxes/peers/add_bot_to_chat_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_bot_to_chat_box.cpp @@ -170,11 +170,15 @@ void AddBotToGroupBoxController::requestExistingRights( channel); _existingRights = participant.rights().flags; _existingRank = participant.rank(); + _promotedSince = participant.promotedSince(); + _promotedBy = participant.by(); addBotToGroup(_existingRightsChannel); }); }).fail([=] { _existingRights = ChatAdminRights(); _existingRank = QString(); + _promotedSince = 0; + _promotedBy = 0; addBotToGroup(_existingRightsChannel); }).send(); } @@ -191,6 +195,8 @@ void AddBotToGroupBoxController::addBotToGroup(not_null chat) { _existingRights = {}; _existingRank = QString(); _existingRightsChannel = nullptr; + _promotedSince = 0; + _promotedBy = 0; _bot->session().api().request(_existingRightsRequestId).cancel(); } const auto requestedAddAdmin = (_scope == Scope::GroupAdmin) @@ -241,9 +247,12 @@ void AddBotToGroupBoxController::addBotToGroup(not_null chat) { bot, ChatAdminRightsInfo(rights), _existingRank, + _promotedSince, + _promotedBy ? chat->owner().user(_promotedBy) : nullptr, EditAdminBotFields{ _token, - _existingRights.value_or(ChatAdminRights()) }); + _existingRights.value_or(ChatAdminRights()), + }); box->setSaveCallback(saveCallback); controller->show(std::move(box)); } else { diff --git a/Telegram/SourceFiles/boxes/peers/add_bot_to_chat_box.h b/Telegram/SourceFiles/boxes/peers/add_bot_to_chat_box.h index 350259a27..f1011a4d7 100644 --- a/Telegram/SourceFiles/boxes/peers/add_bot_to_chat_box.h +++ b/Telegram/SourceFiles/boxes/peers/add_bot_to_chat_box.h @@ -65,6 +65,8 @@ private: mtpRequestId _existingRightsRequestId = 0; std::optional _existingRights; QString _existingRank; + TimeId _promotedSince = 0; + UserId _promotedBy = 0; rpl::event_stream> _groups; rpl::event_stream> _channels; diff --git a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp index e995864c4..bf30fe544 100644 --- a/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_participants_box.cpp @@ -1276,7 +1276,9 @@ void AddSpecialBoxController::showAdmin( _peer, user, currentRights, - _additional.adminRank(user)); + _additional.adminRank(user), + _additional.adminPromotedSince(user), + _additional.adminPromotedBy(user)); const auto show = delegate()->peerListUiShow(); if (_additional.canAddOrEditAdmin(user)) { const auto done = crl::guard(this, [=]( diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index f72ddcc6d..878314812 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -206,6 +206,8 @@ EditAdminBox::EditAdminBox( not_null user, ChatAdminRightsInfo rights, const QString &rank, + TimeId promotedSince, + UserData *by, std::optional addingBot) : EditParticipantBox( nullptr, @@ -214,6 +216,8 @@ EditAdminBox::EditAdminBox( (rights.flags != 0)) , _oldRights(rights) , _oldRank(rank) +, _promotedSince(promotedSince) +, _by(by) , _addingBot(std::move(addingBot)) { } @@ -288,8 +292,26 @@ void EditAdminBox::prepare() { object_ptr(this))); const auto inner = _adminControlsWrap->entity(); - Ui::AddDivider(inner); - Ui::AddSkip(inner); + if (_promotedSince) { + const auto parsed = base::unixtime::parse(_promotedSince); + const auto label = Ui::AddDividerText( + inner, + tr::lng_rights_about_by( + lt_user, + rpl::single(_by + ? Ui::Text::Link(_by->name(), 1) + : TextWithEntities(QString::fromUtf8("\U0001F47B"))), + lt_date, + rpl::single(TextWithEntities{ langDateTimeFull(parsed) }), + Ui::Text::WithEntities)); + if (_by) { + label->setLink(1, _by->createOpenLink()); + } + Ui::AddSkip(inner); + } else { + Ui::AddDivider(inner); + Ui::AddSkip(inner); + } const auto chat = peer()->asChat(); const auto channel = peer()->asChannel(); diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.h b/Telegram/SourceFiles/boxes/peers/edit_participant_box.h index e9a80c0ae..1e5c9fd8a 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.h @@ -79,6 +79,8 @@ public: not_null user, ChatAdminRightsInfo rights, const QString &rank, + TimeId promotedSince, + UserData *by, std::optional addingBot = {}); void setSaveCallback( @@ -130,6 +132,8 @@ private: mtpRequestId _transferRequestId = 0; Fn _save, _finishSave; + TimeId _promotedSince = 0; + UserData *_by = nullptr; std::optional _addingBot; }; diff --git a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp index a96c7602f..345d9880e 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participants_box.cpp @@ -1748,7 +1748,9 @@ void ParticipantsBoxController::showAdmin(not_null user) { _peer, user, currentRights, - _additional.adminRank(user)); + _additional.adminRank(user), + _additional.adminPromotedSince(user), + _additional.adminPromotedBy(user)); if (_additional.canAddOrEditAdmin(user)) { const auto done = crl::guard(this, [=]( ChatAdminRightsInfo newRights,