mirror of
https://github.com/matrix-construct/construct
synced 2025-03-16 22:41:46 +01:00
ircd:Ⓜ️ Add convenience suite to get or check the room creator's user id.
This commit is contained in:
parent
e209d1661b
commit
8733e16ca4
2 changed files with 45 additions and 0 deletions
|
@ -30,6 +30,8 @@ namespace ircd::m
|
|||
bool exists(const id::room_alias &, const bool &remote = false);
|
||||
uint version(const id::room &);
|
||||
bool federate(const id::room &);
|
||||
id::user::buf creator(const id::room &);
|
||||
bool creator(const id::room &, const id::user &);
|
||||
|
||||
// [GET]
|
||||
id::room room_id(const mutable_buffer &, const id::room_alias &);
|
||||
|
|
|
@ -167,6 +167,49 @@ ircd::m::version(const id::room &room_id)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::creator(const id::room &room_id,
|
||||
const id::user &user_id)
|
||||
{
|
||||
const auto creator_user_id
|
||||
{
|
||||
creator(room_id)
|
||||
};
|
||||
|
||||
return creator_user_id == user_id;
|
||||
}
|
||||
|
||||
ircd::m::id::user::buf
|
||||
ircd::m::creator(const id::room &room_id)
|
||||
{
|
||||
// Query the sender field of the event to get the creator. This is for
|
||||
// future compatibility if the content.creator field gets eliminated.
|
||||
static const event::fetch::opts fopts
|
||||
{
|
||||
event::keys::include
|
||||
{
|
||||
"sender",
|
||||
}
|
||||
};
|
||||
|
||||
const room::state state
|
||||
{
|
||||
room_id, &fopts
|
||||
};
|
||||
|
||||
id::user::buf ret;
|
||||
state.get("m.room.create", "", [&ret]
|
||||
(const m::event &event)
|
||||
{
|
||||
ret = user::id
|
||||
{
|
||||
json::get<"sender"_>(event)
|
||||
};
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::federate(const id::room &room_id)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue