mirror of
https://github.com/matrix-construct/construct
synced 2024-06-10 22:18:54 +02:00
modules/federation: Add rooms module; add complexity handler stub.
This commit is contained in:
parent
5fe4d8c4ad
commit
ca29c2ef7b
|
@ -243,6 +243,7 @@ federation_federation_publicrooms_la_SOURCES = federation/publicrooms.cc
|
|||
federation_federation_user_devices_la_SOURCES = federation/user_devices.cc
|
||||
federation_federation_user_keys_query_la_SOURCES = federation/user_keys_query.cc
|
||||
federation_federation_user_keys_claim_la_SOURCES = federation/user_keys_claim.cc
|
||||
federation_federation_rooms_la_SOURCES = federation/rooms.cc
|
||||
|
||||
federation_module_LTLIBRARIES = \
|
||||
federation/federation_send.la \
|
||||
|
@ -268,6 +269,7 @@ federation_module_LTLIBRARIES = \
|
|||
federation/federation_user_devices.la \
|
||||
federation/federation_user_keys_query.la \
|
||||
federation/federation_user_keys_claim.la \
|
||||
federation/federation_rooms.la \
|
||||
###
|
||||
|
||||
###############################################################################
|
||||
|
|
106
modules/federation/rooms.cc
Normal file
106
modules/federation/rooms.cc
Normal file
|
@ -0,0 +1,106 @@
|
|||
// The Construct
|
||||
//
|
||||
// Copyright (C) The Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2020 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;
|
||||
|
||||
m::resource::response
|
||||
get__rooms__complexity(client &client,
|
||||
const m::resource::request &request,
|
||||
const m::room::id &room_id);
|
||||
|
||||
m::resource::response
|
||||
get__rooms(client &client,
|
||||
const m::resource::request &request);
|
||||
|
||||
mapi::header
|
||||
IRCD_MODULE
|
||||
{
|
||||
"Federation Rooms (undocumented)"
|
||||
};
|
||||
|
||||
m::resource
|
||||
rooms_resource
|
||||
{
|
||||
"/_matrix/federation/unstable/rooms/",
|
||||
{
|
||||
"federation rooms (unstable) (undocumented)",
|
||||
resource::DIRECTORY,
|
||||
}
|
||||
};
|
||||
|
||||
m::resource::method
|
||||
method_get
|
||||
{
|
||||
rooms_resource, "GET", get__rooms,
|
||||
{
|
||||
method_get.VERIFY_ORIGIN
|
||||
}
|
||||
};
|
||||
|
||||
m::resource::response
|
||||
get__rooms(client &client,
|
||||
const m::resource::request &request)
|
||||
{
|
||||
if(request.parv.size() < 1)
|
||||
throw m::NEED_MORE_PARAMS
|
||||
{
|
||||
"room_id path parameter required"
|
||||
};
|
||||
|
||||
m::room::id::buf room_id
|
||||
{
|
||||
url::decode(room_id, request.parv[0])
|
||||
};
|
||||
|
||||
if(m::room::server_acl::enable_read && !m::room::server_acl::check(room_id, request.node_id))
|
||||
throw m::ACCESS_DENIED
|
||||
{
|
||||
"You are not permitted by the room's server access control list."
|
||||
};
|
||||
|
||||
if(request.parv.size() < 2)
|
||||
throw m::NEED_MORE_PARAMS
|
||||
{
|
||||
"operation path parameter required"
|
||||
};
|
||||
|
||||
char command_buf[128];
|
||||
const string_view command
|
||||
{
|
||||
url::decode(command_buf, request.parv[1])
|
||||
};
|
||||
|
||||
if(command == "complexity")
|
||||
return get__rooms__complexity(client, request, room_id);
|
||||
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"Unknown federation rooms command"
|
||||
};
|
||||
}
|
||||
|
||||
m::resource::response
|
||||
get__rooms__complexity(client &client,
|
||||
const m::resource::request &request,
|
||||
const m::room::id &room_id)
|
||||
{
|
||||
const float complexity
|
||||
{
|
||||
0.00
|
||||
};
|
||||
|
||||
return resource::response
|
||||
{
|
||||
client, json::members
|
||||
{
|
||||
{ "v1", complexity }
|
||||
}
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue