mirror of
https://github.com/matrix-construct/construct
synced 2025-01-13 08:23:56 +01:00
ircd:Ⓜ️:v1: Add ctor stack complex for user::keys::query.
This commit is contained in:
parent
b687d63169
commit
d5f03fba59
2 changed files with 109 additions and 9 deletions
|
@ -43,13 +43,37 @@ struct ircd::m::v1::user::keys::query
|
|||
{
|
||||
using opts = v1::user::opts;
|
||||
|
||||
using devices = vector_view<const string_view>;
|
||||
using user_devices = std::pair<m::user::id, devices>;
|
||||
|
||||
explicit operator json::object() const
|
||||
{
|
||||
const json::object object{in.content};
|
||||
return object;
|
||||
}
|
||||
|
||||
explicit query(const json::object &content, const mutable_buffer &, opts);
|
||||
explicit
|
||||
query(const json::object &content,
|
||||
const mutable_buffer &,
|
||||
opts);
|
||||
|
||||
query(const vector_view<const user_devices> &,
|
||||
const mutable_buffer &,
|
||||
opts);
|
||||
|
||||
query(const user_devices &,
|
||||
const mutable_buffer &,
|
||||
opts);
|
||||
|
||||
query(const m::user::id &,
|
||||
const string_view &device_id,
|
||||
const mutable_buffer &,
|
||||
opts);
|
||||
|
||||
query(const m::user::id &,
|
||||
const mutable_buffer &,
|
||||
opts);
|
||||
|
||||
query() = default;
|
||||
};
|
||||
|
||||
|
|
92
ircd/m_v1.cc
92
ircd/m_v1.cc
|
@ -774,6 +774,84 @@ ircd::m::v1::make_join::make_join(const room::id &room_id,
|
|||
// v1/user.h
|
||||
//
|
||||
|
||||
ircd::m::v1::user::keys::query::query(const m::user::id &user_id,
|
||||
const mutable_buffer &buf,
|
||||
opts opts)
|
||||
:query
|
||||
{
|
||||
user_id,
|
||||
string_view{},
|
||||
buf,
|
||||
std::move(opts)
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
ircd::m::v1::user::keys::query::query(const m::user::id &user_id,
|
||||
const string_view &device_id,
|
||||
const mutable_buffer &buf,
|
||||
opts opts)
|
||||
:query
|
||||
{
|
||||
user_devices
|
||||
{
|
||||
user_id, vector_view<const string_view>
|
||||
{
|
||||
&device_id, !empty(device_id)
|
||||
}
|
||||
},
|
||||
buf,
|
||||
std::move(opts)
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
ircd::m::v1::user::keys::query::query(const user_devices &v,
|
||||
const mutable_buffer &buf,
|
||||
opts opts)
|
||||
:query
|
||||
{
|
||||
vector_view<const user_devices>
|
||||
{
|
||||
&v, 1
|
||||
},
|
||||
buf,
|
||||
std::move(opts)
|
||||
}
|
||||
{
|
||||
}
|
||||
|
||||
ircd::m::v1::user::keys::query::query(const vector_view<const user_devices> &v,
|
||||
const mutable_buffer &buf,
|
||||
opts opts)
|
||||
{
|
||||
json::stack out{buf};
|
||||
{
|
||||
json::stack::object top{out};
|
||||
json::stack::object device_keys
|
||||
{
|
||||
top, "device_keys"
|
||||
};
|
||||
|
||||
for(const user_devices &ud : v)
|
||||
{
|
||||
json::stack::member user
|
||||
{
|
||||
device_keys, ud.first
|
||||
};
|
||||
|
||||
json::stack::array devices{user};
|
||||
for(const string_view &device_id : ud.second)
|
||||
devices.append(device_id);
|
||||
}
|
||||
}
|
||||
|
||||
new (this) query
|
||||
{
|
||||
json::object(out.completed()), buf + size(out.completed()), std::move(opts)
|
||||
};
|
||||
}
|
||||
|
||||
ircd::m::v1::user::keys::query::query(const json::object &content,
|
||||
const mutable_buffer &buf,
|
||||
opts opts)
|
||||
|
@ -790,14 +868,13 @@ ircd::m::v1::user::keys::query::query(const json::object &content,
|
|||
if(!defined(json::get<"uri"_>(opts.request)))
|
||||
json::get<"uri"_>(opts.request) = "/_matrix/federation/v1/user/keys/query";
|
||||
|
||||
if(defined(json::get<"content"_>(opts.request)))
|
||||
opts.out.content = json::get<"content"_>(opts.request);
|
||||
else
|
||||
opts.out.content = content;
|
||||
if(!defined(json::get<"content"_>(opts.request)))
|
||||
json::get<"content"_>(opts.request) = content;
|
||||
|
||||
if(!defined(json::get<"method"_>(opts.request)))
|
||||
json::get<"method"_>(opts.request) = "POST";
|
||||
|
||||
opts.out.content = json::get<"content"_>(opts.request);
|
||||
opts.out.head = opts.request(buf);
|
||||
|
||||
if(!size(opts.in))
|
||||
|
@ -832,14 +909,13 @@ ircd::m::v1::user::keys::claim::claim(const json::object &content,
|
|||
if(!defined(json::get<"uri"_>(opts.request)))
|
||||
json::get<"uri"_>(opts.request) = "/_matrix/federation/v1/user/keys/claim";
|
||||
|
||||
if(defined(json::get<"content"_>(opts.request)))
|
||||
opts.out.content = json::get<"content"_>(opts.request);
|
||||
else
|
||||
opts.out.content = content;
|
||||
if(!defined(json::get<"content"_>(opts.request)))
|
||||
json::get<"content"_>(opts.request) = content;
|
||||
|
||||
if(!defined(json::get<"method"_>(opts.request)))
|
||||
json::get<"method"_>(opts.request) = "POST";
|
||||
|
||||
opts.out.content = json::get<"content"_>(opts.request);
|
||||
opts.out.head = opts.request(buf);
|
||||
|
||||
if(!size(opts.in))
|
||||
|
|
Loading…
Reference in a new issue