mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd:Ⓜ️ Start a users coarse convenience interface.
This commit is contained in:
parent
002dea97ec
commit
33aea3fd19
4 changed files with 71 additions and 0 deletions
|
@ -38,6 +38,7 @@ namespace ircd::m::vm
|
|||
#include "vm.h"
|
||||
#include "room.h"
|
||||
#include "user.h"
|
||||
#include "users.h"
|
||||
#include "rooms.h"
|
||||
#include "filter.h"
|
||||
#include "events.h"
|
||||
|
|
18
include/ircd/m/users.h
Normal file
18
include/ircd/m/users.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Matrix Construct
|
||||
//
|
||||
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
// copyright notice and this permission notice is present in all copies. The
|
||||
// full license for this software is available in the LICENSE file.
|
||||
|
||||
#pragma once
|
||||
#define HAVE_IRCD_M_USERS_H
|
||||
|
||||
namespace ircd::m::users
|
||||
{
|
||||
bool for_each(const user::closure_bool &);
|
||||
void for_each(const user::closure &);
|
||||
}
|
36
ircd/m/m.cc
36
ircd/m/m.cc
|
@ -1549,6 +1549,42 @@ ircd::m::rooms::for_each(const room::id::closure_bool &closure)
|
|||
}});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// m/users.h
|
||||
//
|
||||
|
||||
void
|
||||
ircd::m::users::for_each(const user::closure &closure)
|
||||
{
|
||||
for_each(user::closure_bool{[&closure]
|
||||
(const m::user &user)
|
||||
{
|
||||
closure(user);
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::users::for_each(const user::closure_bool &closure)
|
||||
{
|
||||
const m::room::state state
|
||||
{
|
||||
user::users
|
||||
};
|
||||
|
||||
return state.for_each("ircd.user", m::room::state::keys_bool{[&closure]
|
||||
(const string_view &user_id)
|
||||
{
|
||||
const m::user &user
|
||||
{
|
||||
user_id
|
||||
};
|
||||
|
||||
return closure(user);
|
||||
}});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// m/user.h
|
||||
|
|
|
@ -7232,6 +7232,22 @@ console_cmd__user__events__count(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// users
|
||||
//
|
||||
|
||||
bool
|
||||
console_cmd__users(opt &out, const string_view &line)
|
||||
{
|
||||
m::users::for_each([&out]
|
||||
(const m::user &user)
|
||||
{
|
||||
out << user.user_id << std::endl;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// typing
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue