diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 372528169..2e3f5284d 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2226,6 +2226,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_admin_log_stopped_poll" = "{from} stopped poll:"; "lng_admin_log_invited" = "invited {user}"; "lng_admin_log_banned" = "banned {user}"; +"lng_admin_log_unbanned" = "unbanned {user}"; "lng_admin_log_restricted" = "changed restrictions for {user} {until}"; "lng_admin_log_promoted" = "changed privileges for {user}"; "lng_admin_log_transferred" = "transferred ownership to {user}"; diff --git a/Telegram/Resources/tl/api.tl b/Telegram/Resources/tl/api.tl index 364d793de..22bc8cf22 100644 --- a/Telegram/Resources/tl/api.tl +++ b/Telegram/Resources/tl/api.tl @@ -621,7 +621,7 @@ channelParticipantSelf#a3289a6d user_id:int inviter_id:int date:int = ChannelPar channelParticipantCreator#447dca4b flags:# user_id:int admin_rights:ChatAdminRights rank:flags.0?string = ChannelParticipant; channelParticipantAdmin#ccbebbaf flags:# can_edit:flags.0?true self:flags.1?true user_id:int inviter_id:flags.1?int promoted_by:int date:int admin_rights:ChatAdminRights rank:flags.2?string = ChannelParticipant; channelParticipantBanned#50a1dfd6 flags:# left:flags.0?true peer:Peer kicked_by:int date:int banned_rights:ChatBannedRights = ChannelParticipant; -channelParticipantLeft#c3c6796b user_id:int = ChannelParticipant; +channelParticipantLeft#1b03f006 peer:Peer = ChannelParticipant; channelParticipantsRecent#de3f3c79 = ChannelParticipantsFilter; channelParticipantsAdmins#b4608969 = ChannelParticipantsFilter; diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 7734a5353..06c6c1650 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1526,6 +1526,8 @@ void ApiWrap::applyLastParticipantsList( const auto participantId = p.match([]( const MTPDchannelParticipantBanned &data) { return peerFromMTP(data.vpeer()); + }, [](const MTPDchannelParticipantLeft &data) { + return peerFromMTP(data.vpeer()); }, [](const auto &data) { return peerFromUser(data.vuser_id()); }); @@ -1614,6 +1616,8 @@ void ApiWrap::applyBotsList( const auto participantId = p.match([]( const MTPDchannelParticipantBanned &data) { return peerFromMTP(data.vpeer()); + }, [](const MTPDchannelParticipantLeft &data) { + return peerFromMTP(data.vpeer()); }, [](const auto &data) { return peerFromUser(data.vuser_id()); }); @@ -3197,6 +3201,8 @@ void ApiWrap::refreshChannelAdmins( const auto participantId = p.match([]( const MTPDchannelParticipantBanned &data) { return peerFromMTP(data.vpeer()); + }, [](const MTPDchannelParticipantLeft &data) { + return peerFromMTP(data.vpeer()); }, [](const auto &data) { return peerFromUser(data.vuser_id()); }); diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp index 35b1ba5ab..b70b0fa61 100644 --- a/Telegram/SourceFiles/data/data_channel.cpp +++ b/Telegram/SourceFiles/data/data_channel.cpp @@ -928,6 +928,8 @@ void ApplyMegagroupAdmins( const auto participantId = p.match([]( const MTPDchannelParticipantBanned &data) { return peerFromMTP(data.vpeer()); + }, [](const MTPDchannelParticipantLeft &data) { + return peerFromMTP(data.vpeer()); }, [](const auto &data) { return peerFromUser(data.vuser_id()); }); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp index 603452b4e..e9ee9b9eb 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_inner.cpp @@ -435,6 +435,8 @@ void InnerWidget::requestAdmins() { const auto participantId = p.match([]( const MTPDchannelParticipantBanned &data) { return peerFromMTP(data.vpeer()); + }, [](const MTPDchannelParticipantLeft &data) { + return peerFromMTP(data.vpeer()); }, [](const auto &data) { return peerFromUser(data.vuser_id()); }); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp index fae37a714..c50df78ea 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -227,6 +227,7 @@ QString GenerateBannedChangeText( } TextWithEntities GenerateBannedChangeText( + PeerId participantId, const TextWithEntities &user, const MTPChatBannedRights *newRights, const MTPChatBannedRights *prevRights) { @@ -235,9 +236,12 @@ TextWithEntities GenerateBannedChangeText( auto newFlags = newRights ? Data::ChatBannedRightsFlags(*newRights) : Flags(0); auto newUntil = newRights ? Data::ChatBannedRightsUntilDate(*newRights) : TimeId(0); + auto prevFlags = prevRights ? Data::ChatBannedRightsFlags(*prevRights) : Flags(0); auto indefinitely = ChannelData::IsRestrictedForever(newUntil); if (newFlags & Flag::f_view_messages) { return tr::lng_admin_log_banned(tr::now, lt_user, user, Ui::Text::WithEntities); + } else if (newFlags == 0 && (prevFlags & Flag::f_view_messages) && !peerIsUser(participantId)) { + return tr::lng_admin_log_unbanned(tr::now, lt_user, user, Ui::Text::WithEntities); } auto untilText = indefinitely ? tr::lng_admin_log_restricted_forever(tr::now) @@ -341,9 +345,9 @@ TextWithEntities GenerateInviteLinkChangeText( auto GenerateParticipantString( not_null session, - PeerId peerId) { + PeerId participantId) { // User name in "User name (@username)" format with entities. - auto peer = session->data().peer(peerId); + auto peer = session->data().peer(participantId); auto name = TextWithEntities { peer->name }; if (const auto user = peer->asUser()) { auto entityData = QString::number(user->id) @@ -378,6 +382,25 @@ auto GenerateParticipantChangeTextInner( const MTPChannelParticipant &participant, const MTPChannelParticipant *oldParticipant) { const auto oldType = oldParticipant ? oldParticipant->type() : 0; + const auto generateOther = [&](PeerId participantId) { + auto user = GenerateParticipantString( + &channel->session(), + participantId); + if (oldType == mtpc_channelParticipantAdmin) { + return GenerateAdminChangeText( + channel, + user, + nullptr, + &oldParticipant->c_channelParticipantAdmin().vadmin_rights()); + } else if (oldType == mtpc_channelParticipantBanned) { + return GenerateBannedChangeText( + participantId, + user, + nullptr, + &oldParticipant->c_channelParticipantBanned().vbanned_rights()); + } + return tr::lng_admin_log_invited(tr::now, lt_user, user, Ui::Text::WithEntities); + }; return participant.match([&](const MTPDchannelParticipantCreator &data) { // No valid string here :( return tr::lng_admin_log_transferred( @@ -395,36 +418,25 @@ auto GenerateParticipantChangeTextInner( channel, user, &data.vadmin_rights(), - (oldType == mtpc_channelParticipantAdmin) + (oldType == mtpc_channelParticipantAdmin ? &oldParticipant->c_channelParticipantAdmin().vadmin_rights() - : nullptr); + : nullptr)); }, [&](const MTPDchannelParticipantBanned &data) { + const auto participantId = peerFromMTP(data.vpeer()); const auto user = GenerateParticipantString( &channel->session(), - peerFromMTP(data.vpeer())); + participantId); return GenerateBannedChangeText( + participantId, user, &data.vbanned_rights(), - (oldType == mtpc_channelParticipantBanned) + (oldType == mtpc_channelParticipantBanned ? &oldParticipant->c_channelParticipantBanned().vbanned_rights() - : nullptr); + : nullptr)); + }, [&](const MTPDchannelParticipantLeft &data) { + return generateOther(peerFromMTP(data.vpeer())); }, [&](const auto &data) { - auto user = GenerateParticipantString( - &channel->session(), - peerFromUser(data.vuser_id())); - if (oldType == mtpc_channelParticipantAdmin) { - return GenerateAdminChangeText( - channel, - user, - nullptr, - &oldParticipant->c_channelParticipantAdmin().vadmin_rights()); - } else if (oldType == mtpc_channelParticipantBanned) { - return GenerateBannedChangeText( - user, - nullptr, - &oldParticipant->c_channelParticipantBanned().vbanned_rights()); - } - return tr::lng_admin_log_invited(tr::now, lt_user, user, Ui::Text::WithEntities); + return generateOther(peerFromUser(data.vuser_id())); }); } diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 82b6a2eda..163a61449 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -1070,6 +1070,8 @@ void PeerMenuAddChannelMembers( ) | ranges::views::transform([](const MTPChannelParticipant &p) { return p.match([](const MTPDchannelParticipantBanned &data) { return peerFromMTP(data.vpeer()); + }, [](const MTPDchannelParticipantLeft &data) { + return peerFromMTP(data.vpeer()); }, [](const auto &data) { return peerFromUser(data.vuser_id()); });