mirror of
https://github.com/matrix-construct/construct
synced 2024-05-29 00:03:45 +02:00
modules/client/room_keys/version: Implement missing PUT replacement functionality.
This commit is contained in:
parent
d41926bc6f
commit
321ea3d641
|
@ -209,11 +209,6 @@ ircd::m::put_room_keys_version(client &client,
|
||||||
event_idx,
|
event_idx,
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto event_id
|
|
||||||
{
|
|
||||||
m::event_id(event_idx)
|
|
||||||
};
|
|
||||||
|
|
||||||
const json::string &algorithm
|
const json::string &algorithm
|
||||||
{
|
{
|
||||||
request["algorithm"]
|
request["algorithm"]
|
||||||
|
@ -224,13 +219,36 @@ ircd::m::put_room_keys_version(client &client,
|
||||||
request["auth_data"]
|
request["auth_data"]
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
const auto event_id
|
||||||
// TODO: XXX
|
{
|
||||||
//
|
m::event_id(event_idx)
|
||||||
|
};
|
||||||
|
|
||||||
|
const json::member relates[]
|
||||||
|
{
|
||||||
|
{ "event_id", event_id },
|
||||||
|
{ "rel_type", "m.replace" },
|
||||||
|
};
|
||||||
|
|
||||||
|
const json::strung content
|
||||||
|
{
|
||||||
|
json::insert(request, json::members
|
||||||
|
{
|
||||||
|
{ "m.relates_to", relates }
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto update_id
|
||||||
|
{
|
||||||
|
m::send(user_room, request.user_id, "ircd.room_keys.version", json::object
|
||||||
|
{
|
||||||
|
content
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
return resource::response
|
return resource::response
|
||||||
{
|
{
|
||||||
client, http::NOT_IMPLEMENTED
|
client, http::OK
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +319,19 @@ ircd::m::get_room_keys_version(client &client,
|
||||||
"No version found.",
|
"No version found.",
|
||||||
};
|
};
|
||||||
|
|
||||||
m::get(event_idx, "content", [&client, &event_idx]
|
const m::replaced latest_idx
|
||||||
|
{
|
||||||
|
event_idx, m::replaced::latest
|
||||||
|
};
|
||||||
|
|
||||||
|
const event::idx version_idx
|
||||||
|
{
|
||||||
|
latest_idx?
|
||||||
|
event::idx{latest_idx}:
|
||||||
|
event_idx
|
||||||
|
};
|
||||||
|
|
||||||
|
m::get(version_idx, "content", [&client, &event_idx]
|
||||||
(const json::object &content)
|
(const json::object &content)
|
||||||
{
|
{
|
||||||
const json::value version
|
const json::value version
|
||||||
|
@ -313,9 +343,9 @@ ircd::m::get_room_keys_version(client &client,
|
||||||
{
|
{
|
||||||
client, json::members
|
client, json::members
|
||||||
{
|
{
|
||||||
{ "version", version },
|
|
||||||
{ "algorithm", content["algorithm"] },
|
{ "algorithm", content["algorithm"] },
|
||||||
{ "auth_data", content["auth_data"] },
|
{ "auth_data", content["auth_data"] },
|
||||||
|
{ "version", version },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue