0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-24 12:58:21 +02:00

modules/client: Add preliminary delete_devices endpoint.

This commit is contained in:
Jason Volk 2019-02-20 09:45:23 -08:00
parent 18a41f81f1
commit d05f58d352
2 changed files with 84 additions and 0 deletions

View file

@ -172,6 +172,7 @@ client_client_joined_groups_la_SOURCES = client/joined_groups.cc
client_client_register_available_la_SOURCES = client/register_available.cc
client_client_capabilities_la_SOURCES = client/capabilities.cc
client_client_send_to_device_la_SOURCES = client/send_to_device.cc
client_client_delete_devices_la_SOURCES = client/delete_devices.cc
client_module_LTLIBRARIES = \
client/client_versions.la \
@ -196,6 +197,7 @@ client_module_LTLIBRARIES = \
client/client_register_available.la \
client/client_capabilities.la \
client/client_send_to_device.la \
client/client_delete_devices.la \
###
#

View file

@ -0,0 +1,82 @@
// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2019 Jason Volk <jason@zemos.net>
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
using namespace ircd;
mapi::header
IRCD_MODULE
{
"Client 14.10.1.5 :Device Management"
};
ircd::resource
delete_devices_resource
{
"/_matrix/client/r0/delete_devices/",
{
"14.10.1.5 :Device Management"
}
};
ircd::resource::redirect::permanent
delete_devices_resource__unstable
{
"/_matrix/client/unstable/delete_devices/",
"/_matrix/client/r0/delete_devices/",
{
"14.10.1.5 :Device Management (redirect)"
}
};
static resource::response
post__delete_devices(client &client,
const resource::request &request);
resource::method
method_post
{
delete_devices_resource, "POST", post__delete_devices,
{
method_post.REQUIRES_AUTH
}
};
resource::response
post__delete_devices(client &client,
const resource::request &request)
{
const json::array &devices
{
request.at("devices")
};
const json::object &auth
{
request["auth"]
};
const string_view &type
{
auth.at("type")
};
const string_view &session
{
auth["session"]
};
for(const json::string &device_id : devices)
m::device::del(request.user_id, device_id);
return resource::response
{
client, http::OK
};
}