mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Allow report / block / delete all from channels.
This commit is contained in:
parent
8d66680a96
commit
5e3b094e86
6 changed files with 21 additions and 21 deletions
|
@ -1757,13 +1757,13 @@ void ApiWrap::unblockParticipant(
|
|||
_kickRequests.emplace(kick, requestId);
|
||||
}
|
||||
|
||||
void ApiWrap::deleteAllFromUser(
|
||||
void ApiWrap::deleteAllFromParticipant(
|
||||
not_null<ChannelData*> channel,
|
||||
not_null<UserData*> from) {
|
||||
not_null<PeerData*> from) {
|
||||
const auto history = _session->data().historyLoaded(channel);
|
||||
const auto ids = history
|
||||
? history->collectMessagesFromUserToDelete(from)
|
||||
: QVector<MsgId>();
|
||||
? history->collectMessagesFromParticipantToDelete(from)
|
||||
: std::vector<MsgId>();
|
||||
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<ChannelData*> channel,
|
||||
not_null<UserData*> from) {
|
||||
not_null<PeerData*> 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();
|
||||
}
|
||||
|
|
|
@ -230,9 +230,9 @@ public:
|
|||
void unblockParticipant(
|
||||
not_null<ChannelData*> channel,
|
||||
not_null<PeerData*> participant);
|
||||
void deleteAllFromUser(
|
||||
void deleteAllFromParticipant(
|
||||
not_null<ChannelData*> channel,
|
||||
not_null<UserData*> from);
|
||||
not_null<PeerData*> 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<ChannelData*> channel,
|
||||
not_null<UserData*> from);
|
||||
not_null<PeerData*> from);
|
||||
|
||||
void uploadAlbumMedia(
|
||||
not_null<HistoryItem*> item,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -3094,13 +3094,13 @@ bool History::removeOrphanMediaGroupPart() {
|
|||
return false;
|
||||
}
|
||||
|
||||
QVector<MsgId> History::collectMessagesFromUserToDelete(
|
||||
not_null<UserData*> user) const {
|
||||
auto result = QVector<MsgId>();
|
||||
std::vector<MsgId> History::collectMessagesFromParticipantToDelete(
|
||||
not_null<PeerData*> participant) const {
|
||||
auto result = std::vector<MsgId>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,8 +101,8 @@ public:
|
|||
Element *findLastDisplayed() const;
|
||||
bool hasOrphanMediaGroupPart() const;
|
||||
bool removeOrphanMediaGroupPart();
|
||||
QVector<MsgId> collectMessagesFromUserToDelete(
|
||||
not_null<UserData*> user) const;
|
||||
[[nodiscard]] std::vector<MsgId> collectMessagesFromParticipantToDelete(
|
||||
not_null<PeerData*> participant) const;
|
||||
|
||||
enum class ClearType {
|
||||
Unload,
|
||||
|
|
Loading…
Add table
Reference in a new issue