0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-03-24 02:10:28 +01:00

modules/client: Stub a send_to_device endpoint.

This commit is contained in:
Jason Volk 2019-02-18 13:39:59 -08:00
parent 3b8130cee1
commit d445f98d93
2 changed files with 77 additions and 0 deletions

View file

@ -167,6 +167,7 @@ client_client_search_la_SOURCES = client/search.cc
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_module_LTLIBRARIES = \
client/client_versions.la \
@ -190,6 +191,7 @@ client_module_LTLIBRARIES = \
client/client_joined_groups.la \
client/client_register_available.la \
client/client_capabilities.la \
client/client_send_to_device.la \
###
#

View file

@ -0,0 +1,75 @@
// Matrix Construct
//
// Copyright (C) Matrix Construct Developers, Authors & Contributors
// Copyright (C) 2016-2018 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.9 :Send-to-Device messaging"
};
ircd::resource
send_to_device_resource
{
"/_matrix/client/r0/sendToDevice/",
{
"(14.9.3) Protocol definitions",
resource::DIRECTORY,
}
};
static resource::response
put__send_to_device(client &client,
const resource::request &request)
{
if(request.parv.size() < 1)
throw m::NEED_MORE_PARAMS
{
"event type path parameter required"
};
char typebuf[m::event::TYPE_MAX_SIZE];
const string_view &type
{
url::decode(typebuf, request.parv[0])
};
if(request.parv.size() < 2)
throw m::NEED_MORE_PARAMS
{
"txnid path parameter required"
};
char txnidbuf[256];
const string_view &txnid
{
url::decode(txnidbuf, request.parv[1])
};
const json::object &messages
{
request["messages"]
};
return resource::response
{
client, http::OK
};
}
resource::method
method_put
{
send_to_device_resource, "PUT", put__send_to_device,
{
method_put.REQUIRES_AUTH
}
};