mirror of
https://github.com/matrix-construct/construct
synced 2025-03-17 15:00:21 +01:00
ircd:Ⓜ️:user::pushers: Additional derivative utils for interface.
This commit is contained in:
parent
7e22894437
commit
3cbf610cd0
2 changed files with 49 additions and 0 deletions
|
@ -19,7 +19,13 @@ struct ircd::m::user::pushers
|
|||
m::user user;
|
||||
|
||||
public:
|
||||
|
||||
bool for_each(const closure_bool &) const;
|
||||
|
||||
size_t count(const string_view &kind = {}) const;
|
||||
bool any(const string_view &kind = {}) const;
|
||||
bool has(const string_view &key) const;
|
||||
|
||||
bool get(std::nothrow_t, const string_view &key, const closure &) const;
|
||||
void get(const string_view &key, const closure &) const;
|
||||
bool set(const json::object &value) const;
|
||||
|
|
|
@ -120,6 +120,49 @@ const
|
|||
});
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::user::pushers::has(const string_view &key)
|
||||
const
|
||||
{
|
||||
return !for_each([&key] // for_each() returns true if no match
|
||||
(const event::idx &pusher_idx, const string_view &pushkey, const push::pusher &pusher)
|
||||
{
|
||||
return key != pushkey;
|
||||
});
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::user::pushers::any(const string_view &kind)
|
||||
const
|
||||
{
|
||||
return !for_each([&kind] // for_each() returns true if no match
|
||||
(const event::idx &pusher_idx, const string_view &pushkey, const push::pusher &pusher)
|
||||
{
|
||||
if(!kind)
|
||||
return false;
|
||||
|
||||
if(json::get<"kind"_>(pusher) == kind)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::m::user::pushers::count(const string_view &kind)
|
||||
const
|
||||
{
|
||||
size_t ret{0};
|
||||
for_each([&ret, &kind]
|
||||
(const event::idx &pusher_idx, const string_view &pushkey, const push::pusher &pusher)
|
||||
{
|
||||
ret += !kind || json::get<"kind"_>(pusher) == kind;
|
||||
return true;
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::user::pushers::for_each(const closure_bool &closure)
|
||||
const
|
||||
|
|
Loading…
Add table
Reference in a new issue