mirror of
https://github.com/matrix-construct/construct
synced 2025-03-16 22:41:46 +01:00
ircd:Ⓜ️:user: Add unit and preliminary interface stubs for pushrules.
This commit is contained in:
parent
da736eb438
commit
0bb52f57a3
4 changed files with 124 additions and 0 deletions
37
include/ircd/m/user/pushrules.h
Normal file
37
include/ircd/m/user/pushrules.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
// 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_PUSHRULES_H
|
||||
|
||||
struct ircd::m::user::pushrules
|
||||
{
|
||||
using path = std::tuple<string_view, string_view, string_view>; // path, kind, ruleid
|
||||
using closure_bool = std::function<bool ()>;
|
||||
using closure = std::function<void ()>;
|
||||
|
||||
m::user user;
|
||||
|
||||
public:
|
||||
bool for_each(const closure_bool &) const;
|
||||
|
||||
bool get(std::nothrow_t, const path &, const closure &) const;
|
||||
void get(const path &, const closure &) const;
|
||||
|
||||
event::id::buf set(const path &, const json::object &value) const;
|
||||
|
||||
pushrules(const m::user &user) noexcept;
|
||||
};
|
||||
|
||||
inline
|
||||
ircd::m::user::pushrules::pushrules(const m::user &user)
|
||||
noexcept
|
||||
:user{user}
|
||||
{}
|
|
@ -43,6 +43,7 @@ struct ircd::m::user
|
|||
struct ignores;
|
||||
struct highlight;
|
||||
struct registar;
|
||||
struct pushrules;
|
||||
|
||||
using id = m::id::user;
|
||||
using closure = std::function<void (const user &)>;
|
||||
|
@ -92,3 +93,4 @@ const
|
|||
#include "ignores.h"
|
||||
#include "highlight.h"
|
||||
#include "register.h"
|
||||
#include "pushrules.h"
|
||||
|
|
|
@ -97,6 +97,7 @@ libircd_matrix_la_SOURCES += user_filter.cc
|
|||
libircd_matrix_la_SOURCES += user_highlight.cc
|
||||
libircd_matrix_la_SOURCES += user_mitsein.cc
|
||||
libircd_matrix_la_SOURCES += user_profile.cc
|
||||
libircd_matrix_la_SOURCES += user_pushrules.cc
|
||||
libircd_matrix_la_SOURCES += user_register.cc
|
||||
libircd_matrix_la_SOURCES += user_room_account_data.cc
|
||||
libircd_matrix_la_SOURCES += user_room_tags.cc
|
||||
|
|
84
matrix/user_pushrules.cc
Normal file
84
matrix/user_pushrules.cc
Normal file
|
@ -0,0 +1,84 @@
|
|||
// 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.
|
||||
|
||||
ircd::m::event::id::buf
|
||||
ircd::m::user::pushrules::set(const path &path,
|
||||
const json::object &value)
|
||||
const
|
||||
{
|
||||
const m::user::room user_room
|
||||
{
|
||||
user
|
||||
};
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void
|
||||
ircd::m::user::pushrules::get(const path &path,
|
||||
const closure &closure)
|
||||
const
|
||||
{
|
||||
if(!get(std::nothrow, path, closure))
|
||||
throw m::NOT_FOUND
|
||||
{
|
||||
"push rule (%s,%s,%s) for user %s not found",
|
||||
std::get<0>(path),
|
||||
std::get<1>(path),
|
||||
std::get<2>(path),
|
||||
string_view{user.user_id}
|
||||
};
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::user::pushrules::get(std::nothrow_t,
|
||||
const path &path,
|
||||
const closure &closure)
|
||||
const
|
||||
{
|
||||
const user::room user_room
|
||||
{
|
||||
user
|
||||
};
|
||||
|
||||
const room::state state
|
||||
{
|
||||
user_room
|
||||
};
|
||||
|
||||
const event::idx &event_idx
|
||||
{
|
||||
0U
|
||||
};
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::m::user::pushrules::for_each(const closure_bool &closure)
|
||||
const
|
||||
{
|
||||
static const event::fetch::opts fopts
|
||||
{
|
||||
event::keys::include {"state_key", "content"}
|
||||
};
|
||||
|
||||
const user::room user_room
|
||||
{
|
||||
user
|
||||
};
|
||||
|
||||
const room::state state
|
||||
{
|
||||
user_room, &fopts
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
Loading…
Add table
Reference in a new issue