mirror of
https://github.com/matrix-construct/construct
synced 2024-06-07 12:38:56 +02:00
ircd:Ⓜ️:room: Implement proper throwing overload for m::version().
This commit is contained in:
parent
3db3770302
commit
362096b34a
|
@ -694,12 +694,27 @@ ircd::string_view
|
|||
ircd::m::version(const mutable_buffer &buf,
|
||||
const room &room)
|
||||
{
|
||||
const auto ret
|
||||
const auto event_idx
|
||||
{
|
||||
version(buf, room, std::nothrow)
|
||||
room.get("m.room.create", "")
|
||||
};
|
||||
|
||||
if(!ret)
|
||||
string_view ret;
|
||||
m::get(event_idx, "content", [&buf, &ret]
|
||||
(const json::object &content)
|
||||
{
|
||||
const json::string &version
|
||||
{
|
||||
content.get("room_version", "1"_sv)
|
||||
};
|
||||
|
||||
ret = strlcpy
|
||||
{
|
||||
buf, version
|
||||
};
|
||||
});
|
||||
|
||||
if(unlikely(!ret))
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"Failed to find room %s to query its version",
|
||||
|
|
Loading…
Reference in a new issue