mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 00:02:34 +01:00
modules/client/groups: Convert joined_groups response stub to chunked json::stack.
This commit is contained in:
parent
748c7730b1
commit
3604e2d078
2 changed files with 69 additions and 39 deletions
|
@ -8,40 +8,68 @@
|
|||
// 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;
|
||||
namespace ircd::m::groups
|
||||
{
|
||||
static resource::response handle_get(client &, const resource::request &);
|
||||
extern resource::method get_joined_groups;
|
||||
extern resource joined_groups_resource;
|
||||
}
|
||||
|
||||
mapi::header
|
||||
ircd::mapi::header
|
||||
IRCD_MODULE
|
||||
{
|
||||
"Client (unspecified) :Joined Groups",
|
||||
};
|
||||
|
||||
resource
|
||||
joined_groups_resource
|
||||
decltype(ircd::m::groups::joined_groups_resource)
|
||||
ircd::m::groups::joined_groups_resource
|
||||
{
|
||||
"/_matrix/client/r0/joined_groups",
|
||||
{
|
||||
"Unspecified"
|
||||
"(Unspecified/undocumented)"
|
||||
}
|
||||
};
|
||||
|
||||
resource::response
|
||||
get__joined_groups(client &client,
|
||||
const resource::request &request)
|
||||
decltype(ircd::m::groups::get_joined_groups)
|
||||
ircd::m::groups::get_joined_groups
|
||||
{
|
||||
return resource::response
|
||||
joined_groups_resource, "GET", handle_get,
|
||||
{
|
||||
client, json::members
|
||||
{
|
||||
//TODO: Unknown yet if "groups" is really a member array, just
|
||||
//TODO: a random guess which doesn't error riot.
|
||||
{ "groups", json::empty_array }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
resource::method
|
||||
get_method
|
||||
{
|
||||
joined_groups_resource, "GET", get__joined_groups
|
||||
get_joined_groups.REQUIRES_AUTH
|
||||
}
|
||||
};
|
||||
|
||||
ircd::m::resource::response
|
||||
ircd::m::groups::handle_get(client &client,
|
||||
const resource::request &request)
|
||||
{
|
||||
resource::response::chunked response
|
||||
{
|
||||
client, http::OK
|
||||
};
|
||||
|
||||
json::stack out
|
||||
{
|
||||
response.buf, response.flusher()
|
||||
};
|
||||
|
||||
json::stack::object top
|
||||
{
|
||||
out
|
||||
};
|
||||
|
||||
json::stack::array groups
|
||||
{
|
||||
top, "groups"
|
||||
};
|
||||
|
||||
const m::id::group group_ids[]
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
// for(const auto &group_id : group_ids)
|
||||
// groups.append(group_id);
|
||||
|
||||
return std::move(response);
|
||||
}
|
||||
|
|
|
@ -62,46 +62,48 @@ ircd::m::sync::groups_linear(data &data)
|
|||
data.membership, membership
|
||||
};
|
||||
|
||||
bool ret{false};
|
||||
json::stack::object _groups
|
||||
{
|
||||
*data.out, "groups"
|
||||
};
|
||||
|
||||
return ret;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::sync::groups_polylog(data &data)
|
||||
{
|
||||
bool ret{false};
|
||||
|
||||
ret |= _groups_polylog(data, "join");
|
||||
if(ret)
|
||||
return ret;
|
||||
|
||||
ret |= _groups_polylog(data, "invite");
|
||||
if(ret)
|
||||
return ret;
|
||||
|
||||
ret |= _groups_polylog(data, "leave");
|
||||
if(ret)
|
||||
return ret;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::sync::_groups_polylog(data &data,
|
||||
const string_view &membership)
|
||||
const string_view &membership)
|
||||
{
|
||||
const scope_restore theirs
|
||||
{
|
||||
data.membership, membership
|
||||
};
|
||||
|
||||
json::stack::object object
|
||||
json::stack::object _groups
|
||||
{
|
||||
*data.out, membership
|
||||
};
|
||||
|
||||
bool ret{false};
|
||||
|
||||
return ret;
|
||||
if(membership != "join")
|
||||
return false;
|
||||
/*
|
||||
for(const auto &group_id : groups)
|
||||
{
|
||||
json::stack::object
|
||||
{
|
||||
_groups, group_id
|
||||
};
|
||||
}
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue