Use Quotient's job for deleting devices
This commit is contained in:
@@ -128,8 +128,6 @@ add_library(neochat STATIC
|
|||||||
neochatconnection.h
|
neochatconnection.h
|
||||||
jobs/neochatdeactivateaccountjob.cpp
|
jobs/neochatdeactivateaccountjob.cpp
|
||||||
jobs/neochatdeactivateaccountjob.h
|
jobs/neochatdeactivateaccountjob.h
|
||||||
jobs/neochatdeletedevicejob.cpp
|
|
||||||
jobs/neochatdeletedevicejob.h
|
|
||||||
jobs/neochatgetcommonroomsjob.cpp
|
jobs/neochatgetcommonroomsjob.cpp
|
||||||
jobs/neochatgetcommonroomsjob.h
|
jobs/neochatgetcommonroomsjob.h
|
||||||
mediasizehelper.cpp
|
mediasizehelper.cpp
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#include "neochatdeletedevicejob.h"
|
|
||||||
|
|
||||||
using namespace Quotient;
|
|
||||||
|
|
||||||
NeochatDeleteDeviceJob::NeochatDeleteDeviceJob(const QString &deviceId, const std::optional<QJsonObject> &auth)
|
|
||||||
: BaseJob(HttpVerb::Delete, u"DeleteDeviceJob"_s, u"/_matrix/client/r0/devices/%1"_s.arg(deviceId).toLatin1())
|
|
||||||
{
|
|
||||||
QJsonObject _data;
|
|
||||||
addParam<IfNotEmpty>(_data, u"auth"_s, auth);
|
|
||||||
setRequestData(std::move(_data));
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
// SPDX-FileCopyrightText: 2023 Tobias Fella <tobias.fella@kde.org>
|
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Quotient/jobs/basejob.h>
|
|
||||||
|
|
||||||
class NeochatDeleteDeviceJob : public Quotient::BaseJob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
explicit NeochatDeleteDeviceJob(const QString &deviceId, const std::optional<QJsonObject> &auth = {});
|
|
||||||
};
|
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include "devicesmodel.h"
|
#include "devicesmodel.h"
|
||||||
|
|
||||||
#include "jobs/neochatdeletedevicejob.h"
|
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
|
||||||
@@ -111,7 +109,7 @@ void DevicesModel::logout(const QString &deviceId, const QString &password)
|
|||||||
for (index = 0; m_devices[index].deviceId != deviceId; index++)
|
for (index = 0; m_devices[index].deviceId != deviceId; index++)
|
||||||
;
|
;
|
||||||
|
|
||||||
auto job = m_connection->callApi<NeochatDeleteDeviceJob>(m_devices[index].deviceId);
|
auto job = m_connection->callApi<DeleteDeviceJob>(m_devices[index].deviceId);
|
||||||
|
|
||||||
connect(job, &BaseJob::result, this, [this, job, password, index] {
|
connect(job, &BaseJob::result, this, [this, job, password, index] {
|
||||||
auto onSuccess = [this, index]() {
|
auto onSuccess = [this, index]() {
|
||||||
@@ -122,13 +120,12 @@ void DevicesModel::logout(const QString &deviceId, const QString &password)
|
|||||||
};
|
};
|
||||||
if (job->error() != BaseJob::Success) {
|
if (job->error() != BaseJob::Success) {
|
||||||
QJsonObject replyData = job->jsonData();
|
QJsonObject replyData = job->jsonData();
|
||||||
QJsonObject authData;
|
AuthenticationData authData;
|
||||||
authData["session"_L1] = replyData["session"_L1];
|
authData.session = replyData["session"_L1].toString();
|
||||||
authData["password"_L1] = password;
|
authData.authInfo["password"_L1] = password;
|
||||||
authData["type"_L1] = "m.login.password"_L1;
|
authData.type = "m.login.password"_L1;
|
||||||
QJsonObject identifier = {{"type"_L1, "m.id.user"_L1}, {"user"_L1, m_connection->user()->id()}};
|
authData.authInfo["identifier"_L1] = QJsonObject{{"type"_L1, "m.id.user"_L1}, {"user"_L1, m_connection->user()->id()}};
|
||||||
authData["identifier"_L1] = identifier;
|
auto innerJob = m_connection->callApi<DeleteDeviceJob>(m_devices[index].deviceId, authData);
|
||||||
auto innerJob = m_connection->callApi<NeochatDeleteDeviceJob>(m_devices[index].deviceId, authData);
|
|
||||||
connect(innerJob.get(), &BaseJob::success, this, onSuccess);
|
connect(innerJob.get(), &BaseJob::success, this, onSuccess);
|
||||||
} else {
|
} else {
|
||||||
onSuccess();
|
onSuccess();
|
||||||
|
|||||||
Reference in New Issue
Block a user