0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-17 07:20:55 +01:00

modules/federation: Explicit path parameter checking for clearer error msgs.

This commit is contained in:
Jason Volk 2019-02-18 10:33:35 -08:00
parent 7e8f3048d3
commit 476f198075
7 changed files with 37 additions and 1 deletions

View file

@ -67,6 +67,12 @@ resource::response
get__backfill(client &client, get__backfill(client &client,
const resource::request &request) const resource::request &request)
{ {
if(request.parv.size() < 1)
throw m::NEED_MORE_PARAMS
{
"room_id path parameter required"
};
m::room::id::buf room_id m::room::id::buf room_id
{ {
url::decode(room_id, request.parv[0]) url::decode(room_id, request.parv[0])

View file

@ -63,6 +63,12 @@ resource::response
get__backfill_ids(client &client, get__backfill_ids(client &client,
const resource::request &request) const resource::request &request)
{ {
if(request.parv.size() < 1)
throw m::NEED_MORE_PARAMS
{
"room_id path parameter required"
};
m::room::id::buf room_id m::room::id::buf room_id
{ {
url::decode(room_id, request.parv[0]) url::decode(room_id, request.parv[0])

View file

@ -33,6 +33,12 @@ resource::response
handle_get(client &client, handle_get(client &client,
const resource::request &request) const resource::request &request)
{ {
if(request.parv.size() < 1)
throw m::NEED_MORE_PARAMS
{
"event_id path parameter required."
};
m::event::id::buf event_id m::event::id::buf event_id
{ {
url::decode(event_id, request.parv[0]) url::decode(event_id, request.parv[0])

View file

@ -93,6 +93,12 @@ resource::response
handle_put(client &client, handle_put(client &client,
const resource::request::object<m::txn> &request) const resource::request::object<m::txn> &request)
{ {
if(request.parv.size() < 1)
throw m::NEED_MORE_PARAMS
{
"txn_id path parameter required"
};
const auto txn_id const auto txn_id
{ {
request.parv[0] request.parv[0]

View file

@ -37,6 +37,12 @@ resource::response
get__state(client &client, get__state(client &client,
const resource::request &request) const resource::request &request)
{ {
if(request.parv.size() < 1)
throw m::NEED_MORE_PARAMS
{
"room_id path parameter required"
};
m::room::id::buf room_id m::room::id::buf room_id
{ {
url::decode(room_id, request.parv[0]) url::decode(room_id, request.parv[0])

View file

@ -30,6 +30,12 @@ resource::response
get__state_ids(client &client, get__state_ids(client &client,
const resource::request &request) const resource::request &request)
{ {
if(request.parv.size() < 1)
throw m::NEED_MORE_PARAMS
{
"room_id path parameter required"
};
m::room::id::buf room_id m::room::id::buf room_id
{ {
url::decode(room_id, request.parv[0]) url::decode(room_id, request.parv[0])

View file

@ -51,7 +51,7 @@ get__user_devices(client &client,
m::user::id::buf user_id m::user::id::buf user_id
{ {
url::decode(user_id, request.parv[1]) url::decode(user_id, request.parv[0])
}; };
return resource::response return resource::response