mirror of
https://github.com/matrix-construct/construct
synced 2024-11-17 07:20:55 +01:00
modules/client: Remove 308 redirects for unstable endpoints.
This commit is contained in:
parent
e90e4aba42
commit
daee236126
7 changed files with 252 additions and 151 deletions
|
@ -10,6 +10,12 @@
|
||||||
|
|
||||||
using namespace ircd;
|
using namespace ircd;
|
||||||
|
|
||||||
|
static resource::response
|
||||||
|
post__delete_devices(client &client,
|
||||||
|
const resource::request &request);
|
||||||
|
|
||||||
|
extern const std::string flows;
|
||||||
|
|
||||||
mapi::header
|
mapi::header
|
||||||
IRCD_MODULE
|
IRCD_MODULE
|
||||||
{
|
{
|
||||||
|
@ -25,20 +31,15 @@ delete_devices_resource
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ircd::resource::redirect::permanent
|
ircd::resource
|
||||||
delete_devices_resource__unstable
|
delete_devices_resource__unstable
|
||||||
{
|
{
|
||||||
"/_matrix/client/unstable/delete_devices/",
|
"/_matrix/client/unstable/delete_devices/",
|
||||||
"/_matrix/client/r0/delete_devices/",
|
|
||||||
{
|
{
|
||||||
"14.10.1.5 :Device Management (redirect)"
|
"14.10.1.5 :Device Management (redirect)"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static resource::response
|
|
||||||
post__delete_devices(client &client,
|
|
||||||
const resource::request &request);
|
|
||||||
|
|
||||||
resource::method
|
resource::method
|
||||||
method_post
|
method_post
|
||||||
{
|
{
|
||||||
|
@ -48,8 +49,14 @@ method_post
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const std::string
|
resource::method
|
||||||
flows;
|
method_post__unstable
|
||||||
|
{
|
||||||
|
delete_devices_resource__unstable, "POST", post__delete_devices,
|
||||||
|
{
|
||||||
|
method_post.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
resource::response
|
resource::response
|
||||||
post__delete_devices(client &client,
|
post__delete_devices(client &client,
|
||||||
|
|
|
@ -10,6 +10,30 @@
|
||||||
|
|
||||||
using namespace ircd;
|
using namespace ircd;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_get_device(json::stack::object &obj,
|
||||||
|
const m::user &user,
|
||||||
|
const string_view &device_id);
|
||||||
|
|
||||||
|
static resource::response
|
||||||
|
get__devices_all(client &client,
|
||||||
|
const resource::request &request,
|
||||||
|
const m::room user_room);
|
||||||
|
|
||||||
|
static resource::response
|
||||||
|
get__devices(client &client,
|
||||||
|
const resource::request &request);
|
||||||
|
|
||||||
|
static resource::response
|
||||||
|
put__devices(client &client,
|
||||||
|
const resource::request &request);
|
||||||
|
|
||||||
|
static resource::response
|
||||||
|
delete__devices(client &client,
|
||||||
|
const resource::request &request);
|
||||||
|
|
||||||
|
extern const std::string flows;
|
||||||
|
|
||||||
mapi::header
|
mapi::header
|
||||||
IRCD_MODULE
|
IRCD_MODULE
|
||||||
{
|
{
|
||||||
|
@ -26,90 +50,69 @@ devices_resource
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ircd::resource::redirect::permanent
|
ircd::resource
|
||||||
devices_resource__unstable
|
devices_resource__unstable
|
||||||
{
|
{
|
||||||
"/_matrix/client/unstable/devices/",
|
"/_matrix/client/unstable/devices/",
|
||||||
"/_matrix/client/r0/devices/",
|
|
||||||
{
|
{
|
||||||
"(11.9) Device Management",
|
"(11.9) Device Management",
|
||||||
resource::DIRECTORY,
|
resource::DIRECTORY,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
resource::method
|
||||||
_get_device(json::stack::object &obj,
|
method_get
|
||||||
const m::user &user,
|
|
||||||
const string_view &device_id)
|
|
||||||
{
|
{
|
||||||
json::stack::member
|
devices_resource, "GET", get__devices,
|
||||||
{
|
{
|
||||||
obj, "device_id", device_id
|
method_get.REQUIRES_AUTH
|
||||||
};
|
|
||||||
|
|
||||||
m::device::get(std::nothrow, user, device_id, "display_name", [&obj]
|
|
||||||
(const string_view &value)
|
|
||||||
{
|
|
||||||
json::stack::member
|
|
||||||
{
|
|
||||||
obj, "display_name", unquote(value)
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
m::device::get(std::nothrow, user, device_id, "last_seen_ip", [&obj]
|
|
||||||
(const string_view &value)
|
|
||||||
{
|
|
||||||
json::stack::member
|
|
||||||
{
|
|
||||||
obj, "last_seen_ip", unquote(value)
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
m::device::get(std::nothrow, user, device_id, "last_seen_ts", [&obj]
|
|
||||||
(const string_view &value)
|
|
||||||
{
|
|
||||||
json::stack::member
|
|
||||||
{
|
|
||||||
obj, "last_seen_ts", value
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static resource::response
|
|
||||||
get__devices_all(client &client,
|
|
||||||
const resource::request &request,
|
|
||||||
const m::room user_room)
|
|
||||||
{
|
|
||||||
resource::response::chunked response
|
|
||||||
{
|
|
||||||
client, http::OK
|
|
||||||
};
|
};
|
||||||
|
|
||||||
json::stack out
|
resource::method
|
||||||
|
method_get__unstable
|
||||||
{
|
{
|
||||||
response.buf, response.flusher()
|
devices_resource__unstable, "GET", get__devices,
|
||||||
};
|
|
||||||
|
|
||||||
json::stack::object top
|
|
||||||
{
|
{
|
||||||
out
|
method_get.REQUIRES_AUTH
|
||||||
};
|
|
||||||
|
|
||||||
json::stack::array devices
|
|
||||||
{
|
|
||||||
top, "devices"
|
|
||||||
};
|
|
||||||
|
|
||||||
m::device::for_each(request.user_id, [&request, &devices]
|
|
||||||
(const string_view &device_id)
|
|
||||||
{
|
|
||||||
json::stack::object obj{devices};
|
|
||||||
_get_device(obj, request.user_id, device_id);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
resource::method
|
||||||
|
method_delete
|
||||||
|
{
|
||||||
|
devices_resource, "DELETE", delete__devices,
|
||||||
|
{
|
||||||
|
method_delete.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
resource::method
|
||||||
|
method_delete__unstable
|
||||||
|
{
|
||||||
|
devices_resource__unstable, "DELETE", delete__devices,
|
||||||
|
{
|
||||||
|
method_delete.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
resource::method
|
||||||
|
method_put
|
||||||
|
{
|
||||||
|
devices_resource, "PUT", put__devices,
|
||||||
|
{
|
||||||
|
method_put.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
resource::method
|
||||||
|
method_put__unstable
|
||||||
|
{
|
||||||
|
devices_resource__unstable, "PUT", put__devices,
|
||||||
|
{
|
||||||
|
method_put.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
resource::response
|
resource::response
|
||||||
get__devices(client &client,
|
get__devices(client &client,
|
||||||
|
@ -153,15 +156,6 @@ get__devices(client &client,
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
resource::method
|
|
||||||
method_get
|
|
||||||
{
|
|
||||||
devices_resource, "GET", get__devices,
|
|
||||||
{
|
|
||||||
method_get.REQUIRES_AUTH
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
resource::response
|
resource::response
|
||||||
put__devices(client &client,
|
put__devices(client &client,
|
||||||
const resource::request &request)
|
const resource::request &request)
|
||||||
|
@ -188,18 +182,6 @@ put__devices(client &client,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
resource::method
|
|
||||||
method_put
|
|
||||||
{
|
|
||||||
devices_resource, "PUT", put__devices,
|
|
||||||
{
|
|
||||||
method_put.REQUIRES_AUTH
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
extern const std::string
|
|
||||||
flows;
|
|
||||||
|
|
||||||
resource::response
|
resource::response
|
||||||
delete__devices(client &client,
|
delete__devices(client &client,
|
||||||
const resource::request &request)
|
const resource::request &request)
|
||||||
|
@ -243,15 +225,80 @@ delete__devices(client &client,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
resource::method
|
resource::response
|
||||||
method_delete
|
get__devices_all(client &client,
|
||||||
|
const resource::request &request,
|
||||||
|
const m::room user_room)
|
||||||
{
|
{
|
||||||
devices_resource, "DELETE", delete__devices,
|
resource::response::chunked response
|
||||||
{
|
{
|
||||||
method_delete.REQUIRES_AUTH
|
client, http::OK
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
json::stack out
|
||||||
|
{
|
||||||
|
response.buf, response.flusher()
|
||||||
|
};
|
||||||
|
|
||||||
|
json::stack::object top
|
||||||
|
{
|
||||||
|
out
|
||||||
|
};
|
||||||
|
|
||||||
|
json::stack::array devices
|
||||||
|
{
|
||||||
|
top, "devices"
|
||||||
|
};
|
||||||
|
|
||||||
|
m::device::for_each(request.user_id, [&request, &devices]
|
||||||
|
(const string_view &device_id)
|
||||||
|
{
|
||||||
|
json::stack::object obj{devices};
|
||||||
|
_get_device(obj, request.user_id, device_id);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_get_device(json::stack::object &obj,
|
||||||
|
const m::user &user,
|
||||||
|
const string_view &device_id)
|
||||||
|
{
|
||||||
|
json::stack::member
|
||||||
|
{
|
||||||
|
obj, "device_id", device_id
|
||||||
|
};
|
||||||
|
|
||||||
|
m::device::get(std::nothrow, user, device_id, "display_name", [&obj]
|
||||||
|
(const string_view &value)
|
||||||
|
{
|
||||||
|
json::stack::member
|
||||||
|
{
|
||||||
|
obj, "display_name", unquote(value)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
m::device::get(std::nothrow, user, device_id, "last_seen_ip", [&obj]
|
||||||
|
(const string_view &value)
|
||||||
|
{
|
||||||
|
json::stack::member
|
||||||
|
{
|
||||||
|
obj, "last_seen_ip", unquote(value)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
m::device::get(std::nothrow, user, device_id, "last_seen_ts", [&obj]
|
||||||
|
(const string_view &value)
|
||||||
|
{
|
||||||
|
json::stack::member
|
||||||
|
{
|
||||||
|
obj, "last_seen_ts", value
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const std::string
|
const std::string
|
||||||
flows
|
flows
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
|
|
||||||
using namespace ircd;
|
using namespace ircd;
|
||||||
|
|
||||||
|
static resource::response
|
||||||
|
get__keys_changes(client &client,
|
||||||
|
const resource::request &request);
|
||||||
|
|
||||||
mapi::header
|
mapi::header
|
||||||
IRCD_MODULE
|
IRCD_MODULE
|
||||||
{
|
{
|
||||||
|
@ -25,16 +29,33 @@ changes_resource
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ircd::resource::redirect::permanent
|
ircd::resource
|
||||||
changes_resource__unstable
|
changes_resource__unstable
|
||||||
{
|
{
|
||||||
"/_matrix/client/unstable/keys/changes",
|
"/_matrix/client/unstable/keys/changes",
|
||||||
"/_matrix/client/r0/keys/changes",
|
|
||||||
{
|
{
|
||||||
"(14.11.5.2.4) Keys changes",
|
"(14.11.5.2.4) Keys changes",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
resource::method
|
||||||
|
method_get
|
||||||
|
{
|
||||||
|
changes_resource, "GET", get__keys_changes,
|
||||||
|
{
|
||||||
|
method_get.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
resource::method
|
||||||
|
method_get__unstable
|
||||||
|
{
|
||||||
|
changes_resource__unstable, "GET", get__keys_changes,
|
||||||
|
{
|
||||||
|
method_get.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
resource::response
|
resource::response
|
||||||
get__keys_changes(client &client,
|
get__keys_changes(client &client,
|
||||||
const resource::request &request)
|
const resource::request &request)
|
||||||
|
@ -44,12 +65,3 @@ get__keys_changes(client &client,
|
||||||
client, http::OK
|
client, http::OK
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
resource::method
|
|
||||||
method_get
|
|
||||||
{
|
|
||||||
changes_resource, "GET", get__keys_changes,
|
|
||||||
{
|
|
||||||
method_get.REQUIRES_AUTH
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -67,11 +67,10 @@ claim_resource
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ircd::resource::redirect::permanent
|
ircd::resource
|
||||||
claim_resource__unstable
|
claim_resource__unstable
|
||||||
{
|
{
|
||||||
"/_matrix/client/unstable/keys/claim",
|
"/_matrix/client/unstable/keys/claim",
|
||||||
"/_matrix/client/r0/keys/claim",
|
|
||||||
{
|
{
|
||||||
"(14.11.5.2.2) Keys claim",
|
"(14.11.5.2.2) Keys claim",
|
||||||
}
|
}
|
||||||
|
@ -86,6 +85,15 @@ method_post
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
resource::method
|
||||||
|
method_post__unstable
|
||||||
|
{
|
||||||
|
claim_resource__unstable, "POST", post__keys_claim,
|
||||||
|
{
|
||||||
|
method_post.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
conf::item<milliseconds>
|
conf::item<milliseconds>
|
||||||
claim_timeout_default
|
claim_timeout_default
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,16 +67,33 @@ query_resource
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ircd::resource::redirect::permanent
|
ircd::resource
|
||||||
query_resource__unstable
|
query_resource__unstable
|
||||||
{
|
{
|
||||||
"/_matrix/client/unstable/keys/query",
|
"/_matrix/client/unstable/keys/query",
|
||||||
"/_matrix/client/r0/keys/query",
|
|
||||||
{
|
{
|
||||||
"(14.11.5.2.2) Keys query",
|
"(14.11.5.2.2) Keys query",
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
resource::method
|
||||||
|
method_post
|
||||||
|
{
|
||||||
|
query_resource, "POST", post__keys_query,
|
||||||
|
{
|
||||||
|
method_post.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
resource::method
|
||||||
|
method_post__unstable
|
||||||
|
{
|
||||||
|
query_resource__unstable, "POST", post__keys_query,
|
||||||
|
{
|
||||||
|
method_post.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
conf::item<milliseconds>
|
conf::item<milliseconds>
|
||||||
query_timeout_default
|
query_timeout_default
|
||||||
{
|
{
|
||||||
|
@ -98,15 +115,6 @@ query_timeout_max
|
||||||
{ "default", 20000L },
|
{ "default", 20000L },
|
||||||
};
|
};
|
||||||
|
|
||||||
resource::method
|
|
||||||
method_post
|
|
||||||
{
|
|
||||||
query_resource, "POST", post__keys_query,
|
|
||||||
{
|
|
||||||
method_post.REQUIRES_AUTH
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
resource::response
|
resource::response
|
||||||
post__keys_query(client &client,
|
post__keys_query(client &client,
|
||||||
const resource::request &request)
|
const resource::request &request)
|
||||||
|
|
|
@ -10,6 +10,16 @@
|
||||||
|
|
||||||
using namespace ircd;
|
using namespace ircd;
|
||||||
|
|
||||||
|
static void
|
||||||
|
upload_device_keys(client &,
|
||||||
|
const resource::request &,
|
||||||
|
const m::device::id &,
|
||||||
|
const m::device_keys &);
|
||||||
|
|
||||||
|
static resource::response
|
||||||
|
post__keys_upload(client &client,
|
||||||
|
const resource::request &request);
|
||||||
|
|
||||||
mapi::header
|
mapi::header
|
||||||
IRCD_MODULE
|
IRCD_MODULE
|
||||||
{
|
{
|
||||||
|
@ -26,22 +36,33 @@ upload_resource
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ircd::resource::redirect::permanent
|
ircd::resource
|
||||||
upload_resource__unstable
|
upload_resource__unstable
|
||||||
{
|
{
|
||||||
"/_matrix/client/unstable/keys/upload",
|
"/_matrix/client/unstable/keys/upload",
|
||||||
"/_matrix/client/r0/keys/upload",
|
|
||||||
{
|
{
|
||||||
"(14.11.5.2.1) Keys Upload",
|
"(14.11.5.2.1) Keys Upload",
|
||||||
resource::DIRECTORY
|
resource::DIRECTORY
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
resource::method
|
||||||
upload_device_keys(client &,
|
method_post
|
||||||
const resource::request &,
|
{
|
||||||
const m::device::id &,
|
upload_resource, "POST", post__keys_upload,
|
||||||
const m::device_keys &);
|
{
|
||||||
|
method_post.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
resource::method
|
||||||
|
method_post__unstable
|
||||||
|
{
|
||||||
|
upload_resource__unstable, "POST", post__keys_upload,
|
||||||
|
{
|
||||||
|
method_post.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
resource::response
|
resource::response
|
||||||
post__keys_upload(client &client,
|
post__keys_upload(client &client,
|
||||||
|
@ -157,12 +178,3 @@ upload_device_keys(client &client,
|
||||||
json::get<"keys"_>(data) = request["device_keys"];
|
json::get<"keys"_>(data) = request["device_keys"];
|
||||||
m::device::set(request.user_id, data);
|
m::device::set(request.user_id, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
resource::method
|
|
||||||
method_post
|
|
||||||
{
|
|
||||||
upload_resource, "POST", post__keys_upload,
|
|
||||||
{
|
|
||||||
method_post.REQUIRES_AUTH
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -10,6 +10,17 @@
|
||||||
|
|
||||||
using namespace ircd;
|
using namespace ircd;
|
||||||
|
|
||||||
|
static void
|
||||||
|
send_to_device(const string_view &txnid,
|
||||||
|
const m::user::id &sender,
|
||||||
|
const m::user::id &target,
|
||||||
|
const string_view &type,
|
||||||
|
const json::object &message);
|
||||||
|
|
||||||
|
static resource::response
|
||||||
|
put__send_to_device(client &client,
|
||||||
|
const resource::request &request);
|
||||||
|
|
||||||
mapi::header
|
mapi::header
|
||||||
IRCD_MODULE
|
IRCD_MODULE
|
||||||
{
|
{
|
||||||
|
@ -26,29 +37,16 @@ send_to_device_resource
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ircd::resource::redirect::permanent
|
ircd::resource
|
||||||
send_to_device_resource__unstable
|
send_to_device_resource__unstable
|
||||||
{
|
{
|
||||||
"/_matrix/client/unstable/sendToDevice/",
|
"/_matrix/client/unstable/sendToDevice/",
|
||||||
"/_matrix/client/r0/sendToDevice/",
|
|
||||||
{
|
{
|
||||||
"(14.9.3) Protocol definitions",
|
"(14.9.3) Protocol definitions",
|
||||||
resource::DIRECTORY,
|
resource::DIRECTORY,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
|
||||||
send_to_device(const string_view &txnid,
|
|
||||||
const m::user::id &sender,
|
|
||||||
const m::user::id &target,
|
|
||||||
const string_view &type,
|
|
||||||
const json::object &message);
|
|
||||||
|
|
||||||
static resource::response
|
|
||||||
put__send_to_device(client &client,
|
|
||||||
const resource::request &request);
|
|
||||||
|
|
||||||
|
|
||||||
resource::method
|
resource::method
|
||||||
method_put
|
method_put
|
||||||
{
|
{
|
||||||
|
@ -58,6 +56,15 @@ method_put
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
resource::method
|
||||||
|
method_put__unstable
|
||||||
|
{
|
||||||
|
send_to_device_resource__unstable, "PUT", put__send_to_device,
|
||||||
|
{
|
||||||
|
method_put.REQUIRES_AUTH
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
resource::response
|
resource::response
|
||||||
put__send_to_device(client &client,
|
put__send_to_device(client &client,
|
||||||
const resource::request &request)
|
const resource::request &request)
|
||||||
|
|
Loading…
Reference in a new issue