File indexing completed on 2024-12-08 04:34:59
0001 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com> 0002 // SPDX-License-Identifier: LGPL-2.1-or-later 0003 0004 #include "reporteditorbackend.h" 0005 0006 #include "abstractaccount.h" 0007 #include "accountmanager.h" 0008 0009 using namespace Qt::StringLiterals; 0010 0011 ReportEditorBackend::ReportEditorBackend(QObject *parent) 0012 : QObject(parent) 0013 { 0014 } 0015 0016 bool ReportEditorBackend::loading() const 0017 { 0018 return m_loading; 0019 } 0020 0021 void ReportEditorBackend::submit() 0022 { 0023 m_loading = true; 0024 Q_EMIT loadingChanged(); 0025 0026 auto account = AccountManager::instance().selectedAccount(); 0027 0028 QUrlQuery formdata; 0029 0030 formdata.addQueryItem(QStringLiteral("account_id"), m_accountId); 0031 if (!m_comment.isEmpty()) { 0032 formdata.addQueryItem(QStringLiteral("comment"), m_comment); 0033 } 0034 if (!m_postId.isEmpty()) { 0035 formdata.addQueryItem(QStringLiteral("status_ids[]"), m_postId); 0036 } 0037 0038 account->post(account->apiUrl(QStringLiteral("/api/v1/reports")), formdata, true, this, [=](QNetworkReply *) { 0039 Q_EMIT reported(); 0040 }); 0041 } 0042 0043 #include "moc_reporteditorbackend.cpp"