2022-04-17 10:30:08 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#include "boxes/report_messages_box.h"
|
|
|
|
|
|
|
|
#include "api/api_report.h"
|
|
|
|
#include "data/data_peer.h"
|
|
|
|
#include "lang/lang_keys.h"
|
|
|
|
#include "ui/boxes/report_box.h"
|
|
|
|
#include "ui/layers/generic_box.h"
|
|
|
|
#include "window/window_session_controller.h"
|
|
|
|
|
2022-04-17 11:00:21 +00:00
|
|
|
object_ptr<Ui::BoxContent> ReportItemsBox(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
MessageIdsList ids) {
|
|
|
|
return Box([=](not_null<Ui::GenericBox*> box) {
|
|
|
|
using Source = Ui::ReportSource;
|
|
|
|
using Reason = Ui::ReportReason;
|
|
|
|
Ui::ReportReasonBox(box, Source::Message, [=](Reason reason) {
|
|
|
|
Ui::BoxShow(box).showBox(Box([=](not_null<Ui::GenericBox*> box) {
|
|
|
|
const auto show = Ui::BoxShow(box);
|
|
|
|
Ui::ReportDetailsBox(box, [=](const QString &text) {
|
|
|
|
Api::SendReport(peer, reason, text, ids);
|
|
|
|
show.hideLayer();
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
});
|
2022-04-17 10:30:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ShowReportPeerBox(
|
|
|
|
not_null<Window::SessionController*> window,
|
|
|
|
not_null<PeerData*> peer) {
|
|
|
|
struct State {
|
2022-04-17 11:00:21 +00:00
|
|
|
QPointer<Ui::BoxContent> reasonBox;
|
|
|
|
QPointer<Ui::BoxContent> detailsBox;
|
2022-04-17 10:30:08 +00:00
|
|
|
MessageIdsList ids;
|
|
|
|
};
|
|
|
|
const auto state = std::make_shared<State>();
|
|
|
|
const auto chosen = [=](Ui::ReportReason reason) {
|
|
|
|
const auto send = [=](const QString &text) {
|
|
|
|
window->clearChooseReportMessages();
|
|
|
|
Api::SendReport(peer, reason, text, std::move(state->ids));
|
|
|
|
if (const auto strong = state->reasonBox.data()) {
|
|
|
|
strong->closeBox();
|
|
|
|
}
|
|
|
|
if (const auto strong = state->detailsBox.data()) {
|
|
|
|
strong->closeBox();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
if (reason == Ui::ReportReason::Fake
|
|
|
|
|| reason == Ui::ReportReason::Other) {
|
|
|
|
state->ids = {};
|
2022-04-17 11:00:21 +00:00
|
|
|
state->detailsBox = window->show(Box(Ui::ReportDetailsBox, send));
|
2022-04-17 10:30:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
window->showChooseReportMessages(peer, reason, [=](
|
|
|
|
MessageIdsList ids) {
|
|
|
|
state->ids = std::move(ids);
|
2022-04-17 11:00:21 +00:00
|
|
|
state->detailsBox = window->show(Box(Ui::ReportDetailsBox, send));
|
2022-04-17 10:30:08 +00:00
|
|
|
});
|
|
|
|
};
|
2022-04-17 11:00:21 +00:00
|
|
|
state->reasonBox = window->show(Box(
|
2022-04-17 10:30:08 +00:00
|
|
|
Ui::ReportReasonBox,
|
|
|
|
(peer->isBroadcast()
|
|
|
|
? Ui::ReportSource::Channel
|
|
|
|
: peer->isUser()
|
|
|
|
? Ui::ReportSource::Bot
|
|
|
|
: Ui::ReportSource::Group),
|
|
|
|
chosen));
|
|
|
|
}
|