mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 00:32:35 +01:00
ircd:Ⓜ️:user: Start a user::notifications interface.
This commit is contained in:
parent
8445cbf83a
commit
ed54618ca4
3 changed files with 69 additions and 0 deletions
33
include/ircd/m/user/notifications.h
Normal file
33
include/ircd/m/user/notifications.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
// The Construct
|
||||
//
|
||||
// Copyright (C) The Construct Developers, Authors & Contributors
|
||||
// Copyright (C) 2016-2020 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_USER_NOTIFICATIONS_H
|
||||
|
||||
struct ircd::m::user::notifications
|
||||
{
|
||||
struct opts;
|
||||
using closure_bool = std::function<bool (const event::idx &, const json::object &)>;
|
||||
|
||||
m::user user;
|
||||
|
||||
public:
|
||||
bool for_each(const opts &, const closure_bool &) const;
|
||||
|
||||
notifications(const m::user &user) noexcept
|
||||
:user{user}
|
||||
{}
|
||||
};
|
||||
|
||||
struct ircd::m::user::notifications::opts
|
||||
{
|
||||
event::idx from {0};
|
||||
string_view only;
|
||||
};
|
|
@ -44,6 +44,7 @@ struct ircd::m::user
|
|||
struct registar;
|
||||
struct pushrules;
|
||||
struct pushers;
|
||||
struct notifications;
|
||||
|
||||
using id = m::id::user;
|
||||
using closure = std::function<void (const user &)>;
|
||||
|
@ -94,3 +95,4 @@ const
|
|||
#include "register.h"
|
||||
#include "pushrules.h"
|
||||
#include "pushers.h"
|
||||
#include "notifications.h"
|
||||
|
|
|
@ -12101,6 +12101,40 @@ console_cmd__user__pushers(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
console_cmd__user__notifications(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"user_id", "only"
|
||||
}};
|
||||
|
||||
const m::user::id &user_id
|
||||
{
|
||||
param.at("user_id")
|
||||
};
|
||||
|
||||
const m::user::notifications notifications
|
||||
{
|
||||
user_id
|
||||
};
|
||||
|
||||
m::user::notifications::opts opts;
|
||||
opts.only = param["only"];
|
||||
|
||||
notifications.for_each(opts, [&out]
|
||||
(const auto &idx, const json::object ¬ification)
|
||||
{
|
||||
out
|
||||
<< std::right << std::setw(10) << idx << " | "
|
||||
<< notification
|
||||
<< std::endl;
|
||||
return true;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// users
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue