0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01:00

modules/client: Remove 308 redirects for unstable endpoints.

This commit is contained in:
Jason Volk 2019-03-11 10:41:28 -07:00
parent e90e4aba42
commit daee236126
7 changed files with 252 additions and 151 deletions

View file

@ -10,6 +10,12 @@
using namespace ircd;
static resource::response
post__delete_devices(client &client,
const resource::request &request);
extern const std::string flows;
mapi::header
IRCD_MODULE
{
@ -25,20 +31,15 @@ delete_devices_resource
}
};
ircd::resource::redirect::permanent
ircd::resource
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
{
@ -48,8 +49,14 @@ method_post
}
};
extern const std::string
flows;
resource::method
method_post__unstable
{
delete_devices_resource__unstable, "POST", post__delete_devices,
{
method_post.REQUIRES_AUTH
}
};
resource::response
post__delete_devices(client &client,

View file

@ -10,6 +10,30 @@
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
IRCD_MODULE
{
@ -26,90 +50,69 @@ devices_resource
}
};
ircd::resource::redirect::permanent
ircd::resource
devices_resource__unstable
{
"/_matrix/client/unstable/devices/",
"/_matrix/client/r0/devices/",
{
"(11.9) Device Management",
resource::DIRECTORY,
}
};
static void
_get_device(json::stack::object &obj,
const m::user &user,
const string_view &device_id)
resource::method
method_get
{
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::method
method_get__unstable
{
resource::response::chunked response
devices_resource__unstable, "GET", get__devices,
{
client, http::OK
};
method_get.REQUIRES_AUTH
}
};
json::stack out
resource::method
method_delete
{
devices_resource, "DELETE", delete__devices,
{
response.buf, response.flusher()
};
method_delete.REQUIRES_AUTH
}
};
json::stack::object top
resource::method
method_delete__unstable
{
devices_resource__unstable, "DELETE", delete__devices,
{
out
};
method_delete.REQUIRES_AUTH
}
};
json::stack::array devices
resource::method
method_put
{
devices_resource, "PUT", put__devices,
{
top, "devices"
};
method_put.REQUIRES_AUTH
}
};
m::device::for_each(request.user_id, [&request, &devices]
(const string_view &device_id)
resource::method
method_put__unstable
{
devices_resource__unstable, "PUT", put__devices,
{
json::stack::object obj{devices};
_get_device(obj, request.user_id, device_id);
return true;
});
return {};
}
method_put.REQUIRES_AUTH
}
};
resource::response
get__devices(client &client,
@ -153,15 +156,6 @@ get__devices(client &client,
return {};
}
resource::method
method_get
{
devices_resource, "GET", get__devices,
{
method_get.REQUIRES_AUTH
}
};
resource::response
put__devices(client &client,
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
delete__devices(client &client,
const resource::request &request)
@ -243,14 +225,79 @@ delete__devices(client &client,
};
}
resource::method
method_delete
resource::response
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
flows

View file

@ -10,6 +10,10 @@
using namespace ircd;
static resource::response
get__keys_changes(client &client,
const resource::request &request);
mapi::header
IRCD_MODULE
{
@ -25,16 +29,33 @@ changes_resource
}
};
ircd::resource::redirect::permanent
ircd::resource
changes_resource__unstable
{
"/_matrix/client/unstable/keys/changes",
"/_matrix/client/r0/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
get__keys_changes(client &client,
const resource::request &request)
@ -44,12 +65,3 @@ get__keys_changes(client &client,
client, http::OK
};
}
resource::method
method_get
{
changes_resource, "GET", get__keys_changes,
{
method_get.REQUIRES_AUTH
}
};

View file

@ -67,11 +67,10 @@ claim_resource
}
};
ircd::resource::redirect::permanent
ircd::resource
claim_resource__unstable
{
"/_matrix/client/unstable/keys/claim",
"/_matrix/client/r0/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>
claim_timeout_default
{

View file

@ -67,16 +67,33 @@ query_resource
}
};
ircd::resource::redirect::permanent
ircd::resource
query_resource__unstable
{
"/_matrix/client/unstable/keys/query",
"/_matrix/client/r0/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>
query_timeout_default
{
@ -98,15 +115,6 @@ query_timeout_max
{ "default", 20000L },
};
resource::method
method_post
{
query_resource, "POST", post__keys_query,
{
method_post.REQUIRES_AUTH
}
};
resource::response
post__keys_query(client &client,
const resource::request &request)

View file

@ -10,6 +10,16 @@
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
IRCD_MODULE
{
@ -26,22 +36,33 @@ upload_resource
}
};
ircd::resource::redirect::permanent
ircd::resource
upload_resource__unstable
{
"/_matrix/client/unstable/keys/upload",
"/_matrix/client/r0/keys/upload",
{
"(14.11.5.2.1) Keys Upload",
resource::DIRECTORY
}
};
static void
upload_device_keys(client &,
const resource::request &,
const m::device::id &,
const m::device_keys &);
resource::method
method_post
{
upload_resource, "POST", post__keys_upload,
{
method_post.REQUIRES_AUTH
}
};
resource::method
method_post__unstable
{
upload_resource__unstable, "POST", post__keys_upload,
{
method_post.REQUIRES_AUTH
}
};
resource::response
post__keys_upload(client &client,
@ -157,12 +178,3 @@ upload_device_keys(client &client,
json::get<"keys"_>(data) = request["device_keys"];
m::device::set(request.user_id, data);
}
resource::method
method_post
{
upload_resource, "POST", post__keys_upload,
{
method_post.REQUIRES_AUTH
}
};

View file

@ -10,6 +10,17 @@
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
IRCD_MODULE
{
@ -26,29 +37,16 @@ send_to_device_resource
}
};
ircd::resource::redirect::permanent
ircd::resource
send_to_device_resource__unstable
{
"/_matrix/client/unstable/sendToDevice/",
"/_matrix/client/r0/sendToDevice/",
{
"(14.9.3) Protocol definitions",
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
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
put__send_to_device(client &client,
const resource::request &request)