mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-01 07:05:13 +00:00
Moved api for report messages to separated file.
This commit is contained in:
70
Telegram/SourceFiles/api/api_report.cpp
Normal file
70
Telegram/SourceFiles/api/api_report.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
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 "api/api_report.h"
|
||||
|
||||
#include "apiwrap.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "ui/boxes/report_box.h"
|
||||
#include "ui/toast/toast.h"
|
||||
|
||||
namespace Api {
|
||||
|
||||
namespace {
|
||||
|
||||
MTPreportReason ReasonToTL(const Ui::ReportReason &reason) {
|
||||
using Reason = Ui::ReportReason;
|
||||
switch (reason) {
|
||||
case Reason::Spam: return MTP_inputReportReasonSpam();
|
||||
case Reason::Fake: return MTP_inputReportReasonFake();
|
||||
case Reason::Violence: return MTP_inputReportReasonViolence();
|
||||
case Reason::ChildAbuse: return MTP_inputReportReasonChildAbuse();
|
||||
case Reason::Pornography: return MTP_inputReportReasonPornography();
|
||||
case Reason::Copyright: return MTP_inputReportReasonCopyright();
|
||||
case Reason::IllegalDrugs: return MTP_inputReportReasonIllegalDrugs();
|
||||
case Reason::PersonalDetails:
|
||||
return MTP_inputReportReasonPersonalDetails();
|
||||
case Reason::Other: return MTP_inputReportReasonOther();
|
||||
}
|
||||
Unexpected("Bad reason group value.");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void SendReport(
|
||||
not_null<PeerData*> peer,
|
||||
Ui::ReportReason reason,
|
||||
const QString &comment,
|
||||
MessageIdsList ids) {
|
||||
if (ids.empty()) {
|
||||
peer->session().api().request(MTPaccount_ReportPeer(
|
||||
peer->input,
|
||||
ReasonToTL(reason),
|
||||
MTP_string(comment)
|
||||
)).done([=] {
|
||||
Ui::Toast::Show(tr::lng_report_thanks(tr::now));
|
||||
}).send();
|
||||
} else {
|
||||
auto apiIds = QVector<MTPint>();
|
||||
apiIds.reserve(ids.size());
|
||||
for (const auto &fullId : ids) {
|
||||
apiIds.push_back(MTP_int(fullId.msg));
|
||||
}
|
||||
peer->session().api().request(MTPmessages_Report(
|
||||
peer->input,
|
||||
MTP_vector<MTPint>(apiIds),
|
||||
ReasonToTL(reason),
|
||||
MTP_string(comment)
|
||||
)).done([=] {
|
||||
Ui::Toast::Show(tr::lng_report_thanks(tr::now));
|
||||
}).send();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Api
|
Reference in New Issue
Block a user