mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 15:04:10 +01:00
ircd:Ⓜ️ Add viewing(user) for currently viewing room w/ console cmd.
This commit is contained in:
parent
bc7a2edc45
commit
2d0a565ede
3 changed files with 57 additions and 0 deletions
|
@ -21,6 +21,8 @@ namespace ircd::m
|
|||
bool active(const user &);
|
||||
bool is_oper(const user &);
|
||||
|
||||
id::room::buf viewing(const user &, size_t i = 0);
|
||||
|
||||
user create(const id::user &, const json::members &args = {});
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,29 @@ namespace ircd::m
|
|||
static room create_user_room(const user::id &, const room::id &, const json::members &contents);
|
||||
}
|
||||
|
||||
ircd::m::room::id::buf
|
||||
ircd::m::viewing(const user &user,
|
||||
size_t i)
|
||||
{
|
||||
const m::breadcrumbs breadcrumbs
|
||||
{
|
||||
user
|
||||
};
|
||||
|
||||
room::id::buf ret;
|
||||
breadcrumbs.for_each([&ret, &i]
|
||||
(const auto &room_id)
|
||||
{
|
||||
if(i-- > 0)
|
||||
return true;
|
||||
|
||||
ret = room_id;
|
||||
return false;
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::is_oper(const user &user)
|
||||
{
|
||||
|
|
|
@ -13535,6 +13535,38 @@ console_cmd__user__breadcrumbs(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__user__viewing(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"user_id", "idx"
|
||||
}};
|
||||
|
||||
const m::user::id user_id
|
||||
{
|
||||
param.at("user_id")
|
||||
};
|
||||
|
||||
const size_t idx
|
||||
{
|
||||
param.at("idx", 0UL)
|
||||
};
|
||||
|
||||
const m::user user
|
||||
{
|
||||
user_id
|
||||
};
|
||||
|
||||
const auto room_id
|
||||
{
|
||||
m::viewing(user, idx)
|
||||
};
|
||||
|
||||
out << room_id << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__user__pushrules(opt &out, const string_view &line)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue