Skip to content

Commit

Permalink
Added support of admin log event of extended subscriptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd authored and john-preston committed Sep 6, 2024
1 parent 19d386f commit e44aca0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions Telegram/Resources/langs/lang.strings
Original file line number Diff line number Diff line change
Expand Up @@ -4588,6 +4588,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_admin_log_admin_manage_calls" = "Manage voice chats";
"lng_admin_log_admin_manage_calls_channel" = "Manage live streams";
"lng_admin_log_admin_add_admins" = "Add new admins";
"lng_admin_log_subscription_extend" = "{name} renewed subscription until {date}";

"lng_admin_log_antispam_menu_report" = "Report False Positive";
"lng_admin_log_antispam_menu_report_toast" = "You can manage anti-spam settings in {link}.";
Expand Down
13 changes: 13 additions & 0 deletions Telegram/SourceFiles/api/api_chat_participants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ For license and copyright information please follow this link:
#include "api/api_chat_participants.h"

#include "apiwrap.h"
#include "base/unixtime.h"
#include "boxes/add_contact_box.h" // ShowAddParticipantsError
#include "boxes/peers/add_participants_box.h" // ChatInviteForbidden
#include "data/data_changes.h"
Expand Down Expand Up @@ -267,8 +268,16 @@ ChatParticipant::ChatParticipant(
}, [&](const MTPDchannelParticipantSelf &data) {
_type = Type::Member;
_by = peerToUser(peerFromUser(data.vinviter_id()));
if (data.vsubscription_until_date()) {
_subscriptionDate = base::unixtime::parse(
data.vsubscription_until_date()->v);
}
}, [&](const MTPDchannelParticipant &data) {
_type = Type::Member;
if (data.vsubscription_until_date()) {
_subscriptionDate = base::unixtime::parse(
data.vsubscription_until_date()->v);
}
}, [&](const MTPDchannelParticipantBanned &data) {
_restrictions = ChatRestrictionsInfo(data.vbanned_rights());
_by = peerToUser(peerFromUser(data.vkicked_by()));
Expand Down Expand Up @@ -348,6 +357,10 @@ ChatAdminRightsInfo ChatParticipant::rights() const {
return _rights;
}

QDateTime ChatParticipant::subscriptionDate() const {
return _subscriptionDate;
}

ChatParticipant::Type ChatParticipant::type() const {
return _type;
}
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/api/api_chat_participants.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class ChatParticipant final {
ChatRestrictionsInfo restrictions() const;
ChatAdminRightsInfo rights() const;

QDateTime subscriptionDate() const;

Type type() const;
QString rank() const;

Expand All @@ -73,6 +75,7 @@ class ChatParticipant final {
bool _canBeEdited = false;

QString _rank;
QDateTime _subscriptionDate;

ChatRestrictionsInfo _restrictions;
ChatAdminRightsInfo _rights;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,26 @@ void GenerateItems(
};

const auto createParticipantSubExtend = [&](const LogParticipantSubExtend &action) {
AssertIsDebug();
const auto participant = Api::ChatParticipant(
action.vnew_participant(),
channel);
if (participant.subscriptionDate().isNull()) {
return;
}
const auto participantPeer = channel->owner().peer(participant.id());
const auto participantPeerLink = participantPeer->createOpenLink();
const auto participantPeerLinkText = Ui::Text::Link(
participantPeer->name(),
QString());
addServiceMessageWithLink(
tr::lng_admin_log_subscription_extend(
tr::now,
lt_name,
participantPeerLinkText,
lt_date,
{ langDateTimeFull(participant.subscriptionDate()) },
Ui::Text::WithEntities),
participantPeerLink);
};

action.match(
Expand Down

0 comments on commit e44aca0

Please sign in to comment.