diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index bdf844f473..6c7cd9cabc 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -1757,13 +1757,13 @@ void ApiWrap::unblockParticipant( _kickRequests.emplace(kick, requestId); } -void ApiWrap::deleteAllFromUser( +void ApiWrap::deleteAllFromParticipant( not_null channel, - not_null from) { + not_null from) { const auto history = _session->data().historyLoaded(channel); const auto ids = history - ? history->collectMessagesFromUserToDelete(from) - : QVector(); + ? history->collectMessagesFromParticipantToDelete(from) + : std::vector(); const auto channelId = peerToChannel(channel->id); for (const auto &msgId : ids) { if (const auto item = _session->data().message(channelId, msgId)) { @@ -1773,19 +1773,19 @@ void ApiWrap::deleteAllFromUser( _session->data().sendHistoryChangeNotifications(); - deleteAllFromUserSend(channel, from); + deleteAllFromParticipantSend(channel, from); } -void ApiWrap::deleteAllFromUserSend( +void ApiWrap::deleteAllFromParticipantSend( not_null channel, - not_null from) { + not_null from) { request(MTPchannels_DeleteParticipantHistory( channel->inputChannel, from->input )).done([=](const MTPmessages_AffectedHistory &result) { const auto offset = applyAffectedHistory(channel, result); if (offset > 0) { - deleteAllFromUserSend(channel, from); + deleteAllFromParticipantSend(channel, from); } else if (const auto history = _session->data().historyLoaded(channel)) { history->requestChatListMessage(); } diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index f8fdbe4cad..e9d60ff0af 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -230,9 +230,9 @@ public: void unblockParticipant( not_null channel, not_null participant); - void deleteAllFromUser( + void deleteAllFromParticipant( not_null channel, - not_null from); + not_null from); void requestWebPageDelayed(WebPageData *page); void clearWebPageRequest(WebPageData *page); @@ -518,9 +518,9 @@ private: bool revoke); void applyAffectedMessages(const MTPmessages_AffectedMessages &result); - void deleteAllFromUserSend( + void deleteAllFromParticipantSend( not_null channel, - not_null from); + not_null from); void uploadAlbumMedia( not_null item, diff --git a/Telegram/SourceFiles/boxes/delete_messages_box.cpp b/Telegram/SourceFiles/boxes/delete_messages_box.cpp index e1c5050ba1..bcfd3ae27f 100644 --- a/Telegram/SourceFiles/boxes/delete_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/delete_messages_box.cpp @@ -39,7 +39,7 @@ DeleteMessagesBox::DeleteMessagesBox( _moderateBan = item->suggestBanReport(); _moderateDeleteAll = item->suggestDeleteAllReport(); if (_moderateBan || _moderateDeleteAll) { - _moderateFrom = item->from()->asUser(); + _moderateFrom = item->from(); _moderateInChannel = item->history()->peer->asChannel(); } } @@ -492,7 +492,7 @@ void DeleteMessagesBox::deleteAndClear() { ).send(); } if (_deleteAll && _deleteAll->checked()) { - _moderateInChannel->session().api().deleteAllFromUser( + _moderateInChannel->session().api().deleteAllFromParticipant( _moderateInChannel, _moderateFrom); } diff --git a/Telegram/SourceFiles/boxes/delete_messages_box.h b/Telegram/SourceFiles/boxes/delete_messages_box.h index 38bf7d38fd..61b8773e7c 100644 --- a/Telegram/SourceFiles/boxes/delete_messages_box.h +++ b/Telegram/SourceFiles/boxes/delete_messages_box.h @@ -64,7 +64,7 @@ private: const QDate _wipeHistoryFirstToDelete; const QDate _wipeHistoryLastToDelete; const MessageIdsList _ids; - UserData *_moderateFrom = nullptr; + PeerData *_moderateFrom = nullptr; ChannelData *_moderateInChannel = nullptr; bool _moderateBan = false; bool _moderateDeleteAll = false; diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 655415dc05..b1fffd8572 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -3094,13 +3094,13 @@ bool History::removeOrphanMediaGroupPart() { return false; } -QVector History::collectMessagesFromUserToDelete( - not_null user) const { - auto result = QVector(); +std::vector History::collectMessagesFromParticipantToDelete( + not_null participant) const { + auto result = std::vector(); for (const auto &block : blocks) { for (const auto &message : block->messages) { const auto item = message->data(); - if (item->from() == user && item->canDelete()) { + if (item->from() == participant && item->canDelete()) { result.push_back(item->id); } } diff --git a/Telegram/SourceFiles/history/history.h b/Telegram/SourceFiles/history/history.h index 9f2257a84b..0b26a1d0a0 100644 --- a/Telegram/SourceFiles/history/history.h +++ b/Telegram/SourceFiles/history/history.h @@ -101,8 +101,8 @@ public: Element *findLastDisplayed() const; bool hasOrphanMediaGroupPart() const; bool removeOrphanMediaGroupPart(); - QVector collectMessagesFromUserToDelete( - not_null user) const; + [[nodiscard]] std::vector collectMessagesFromParticipantToDelete( + not_null participant) const; enum class ClearType { Unload,