mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 08:12:37 +01:00
modules/client/user: Stub handler for 11.18.2.2 PUT rooms/account_data; fix parv check.
This commit is contained in:
parent
599b53d20b
commit
34d1ea4afc
4 changed files with 93 additions and 1 deletions
|
@ -148,6 +148,7 @@ client_client_user_la_SOURCES = \
|
|||
client/user/openid.cc \
|
||||
client/user/filter.cc \
|
||||
client/user/account_data.cc \
|
||||
client/user/rooms.cc \
|
||||
client/user/user.cc \
|
||||
###
|
||||
|
||||
|
|
72
modules/client/user/rooms.cc
Normal file
72
modules/client/user/rooms.cc
Normal file
|
@ -0,0 +1,72 @@
|
|||
// 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.
|
||||
|
||||
#include "user.h"
|
||||
|
||||
using namespace ircd;
|
||||
|
||||
static resource::response
|
||||
put__account_data(client &client,
|
||||
const resource::request &request,
|
||||
const m::user::id &user_id,
|
||||
const m::room::id &room_id)
|
||||
{
|
||||
if(request.parv.size() < 5)
|
||||
throw m::NEED_MORE_PARAMS
|
||||
{
|
||||
"type required"
|
||||
};
|
||||
|
||||
const string_view &type
|
||||
{
|
||||
request.parv[4]
|
||||
};
|
||||
|
||||
return resource::response
|
||||
{
|
||||
client, http::OK
|
||||
};
|
||||
}
|
||||
|
||||
resource::response
|
||||
put__rooms(client &client,
|
||||
const resource::request &request,
|
||||
const m::user::id &user_id)
|
||||
{
|
||||
if(request.parv.size() < 3)
|
||||
throw m::NEED_MORE_PARAMS
|
||||
{
|
||||
"room_id required"
|
||||
};
|
||||
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(request.parv[2], room_id)
|
||||
};
|
||||
|
||||
if(request.parv.size() < 4)
|
||||
throw m::NEED_MORE_PARAMS
|
||||
{
|
||||
"rooms command required"
|
||||
};
|
||||
|
||||
const string_view &cmd
|
||||
{
|
||||
request.parv[3]
|
||||
};
|
||||
|
||||
if(cmd == "account_data")
|
||||
return put__account_data(client, request, user_id, room_id);
|
||||
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"/user/rooms/ command not found"
|
||||
};
|
||||
}
|
|
@ -108,7 +108,7 @@ post_method
|
|||
resource::response
|
||||
put_user(client &client, const resource::request &request)
|
||||
{
|
||||
if(request.parv.size() < 2)
|
||||
if(request.parv.size() < 1)
|
||||
throw m::NEED_MORE_PARAMS
|
||||
{
|
||||
"user_id required"
|
||||
|
@ -119,6 +119,12 @@ put_user(client &client, const resource::request &request)
|
|||
url::decode(request.parv[0], user_id)
|
||||
};
|
||||
|
||||
if(request.parv.size() < 2)
|
||||
throw m::NEED_MORE_PARAMS
|
||||
{
|
||||
"user command required"
|
||||
};
|
||||
|
||||
const string_view &cmd
|
||||
{
|
||||
request.parv[1]
|
||||
|
@ -127,6 +133,9 @@ put_user(client &client, const resource::request &request)
|
|||
if(cmd == "account_data")
|
||||
return put__account_data(client, request, user_id);
|
||||
|
||||
if(cmd == "rooms")
|
||||
return put__rooms(client, request, user_id);
|
||||
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"/user command not found"
|
||||
|
|
|
@ -44,3 +44,13 @@ ircd::resource::response
|
|||
post__openid(ircd::client &client,
|
||||
const ircd::resource::request &request,
|
||||
const ircd::m::user::id &user_id);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// rooms.cc
|
||||
//
|
||||
|
||||
ircd::resource::response
|
||||
put__rooms(ircd::client &client,
|
||||
const ircd::resource::request &request,
|
||||
const ircd::m::user::id &user_id);
|
||||
|
|
Loading…
Reference in a new issue