Fix incorrect admin log

Type: Restricted to Member
This commit is contained in:
c0re100 2022-01-21 05:48:23 +08:00 committed by John Preston
parent c0a81f2428
commit 4bb3aec168

View file

@ -219,7 +219,7 @@ TextWithEntities GenerateAdminChangeText(
return result; return result;
}; };
QString GenerateBannedChangeText( QString GeneratePermissionsChangeText(
ChatRestrictionsInfo newRights, ChatRestrictionsInfo newRights,
ChatRestrictionsInfo prevRights) { ChatRestrictionsInfo prevRights) {
using Flag = ChatRestriction; using Flag = ChatRestriction;
@ -242,7 +242,7 @@ QString GenerateBannedChangeText(
return CollectChanges(phraseMap, prevRights.flags, newRights.flags); return CollectChanges(phraseMap, prevRights.flags, newRights.flags);
} }
TextWithEntities GenerateBannedChangeText( TextWithEntities GeneratePermissionsChangeText(
PeerId participantId, PeerId participantId,
const TextWithEntities &user, const TextWithEntities &user,
ChatRestrictionsInfo newRights, ChatRestrictionsInfo newRights,
@ -281,7 +281,7 @@ TextWithEntities GenerateBannedChangeText(
lt_until, lt_until,
TextWithEntities { untilText }, TextWithEntities { untilText },
Ui::Text::WithEntities); Ui::Text::WithEntities);
const auto changes = GenerateBannedChangeText(newRights, prevRights); const auto changes = GeneratePermissionsChangeText(newRights, prevRights);
if (!changes.isEmpty()) { if (!changes.isEmpty()) {
result.text.append('\n' + changes); result.text.append('\n' + changes);
} }
@ -478,7 +478,13 @@ auto GenerateParticipantChangeText(
ChatAdminRightsInfo(), ChatAdminRightsInfo(),
oldRights); oldRights);
} else if (oldParticipant && oldParticipant->type() == Type::Banned) { } else if (oldParticipant && oldParticipant->type() == Type::Banned) {
return GenerateBannedChangeText( return GeneratePermissionsChangeText(
participantId,
user,
ChatRestrictionsInfo(),
oldRestrictions);
} else if (oldParticipant && oldParticipant->type() == Type::Restricted && participant.type() == Type::Member) {
return GeneratePermissionsChangeText(
participantId, participantId,
user, user,
ChatRestrictionsInfo(), ChatRestrictionsInfo(),
@ -517,7 +523,7 @@ auto GenerateParticipantChangeText(
const auto user = GenerateParticipantString( const auto user = GenerateParticipantString(
&channel->session(), &channel->session(),
peerId); peerId);
return GenerateBannedChangeText( return GeneratePermissionsChangeText(
peerId, peerId,
user, user,
participant.restrictions(), participant.restrictions(),
@ -556,7 +562,7 @@ TextWithEntities GenerateDefaultBannedRightsChangeText(
auto result = TextWithEntities{ auto result = TextWithEntities{
tr::lng_admin_log_changed_default_permissions(tr::now) tr::lng_admin_log_changed_default_permissions(tr::now)
}; };
const auto changes = GenerateBannedChangeText(rights, oldRights); const auto changes = GeneratePermissionsChangeText(rights, oldRights);
if (!changes.isEmpty()) { if (!changes.isEmpty()) {
result.text.append('\n' + changes); result.text.append('\n' + changes);
} }