mirror of
https://github.com/matrix-construct/construct
synced 2024-06-01 01:28:54 +02:00
modules/vm: Add eval argument to various hooks; tweak eval struct.
This commit is contained in:
parent
71edf65c7c
commit
9232319f0c
|
@ -48,10 +48,10 @@ struct ircd::m::vm::eval
|
|||
{
|
||||
static uint64_t id_ctr; // monotonic
|
||||
|
||||
uint64_t id {++id_ctr};
|
||||
ctx::ctx *ctx {ctx::current};
|
||||
const vm::opts *opts {&default_opts};
|
||||
const vm::copts *copts {nullptr};
|
||||
ctx::ctx *ctx {ctx::current};
|
||||
uint64_t id {++id_ctr};
|
||||
string_view room_id;
|
||||
const json::iov *issue {nullptr};
|
||||
const event *event_ {nullptr};
|
||||
|
|
|
@ -33,9 +33,9 @@ presence_valid_state(const string_view &state)
|
|||
}
|
||||
|
||||
static void handle_edu_m_presence_(const m::event &, const m::presence &edu);
|
||||
static void handle_edu_m_presence(const m::event &);
|
||||
static void handle_edu_m_presence(const m::event &, m::vm::eval &);
|
||||
|
||||
const m::hookfn<>
|
||||
const m::hookfn<m::vm::eval &>
|
||||
_m_presence_eval
|
||||
{
|
||||
handle_edu_m_presence,
|
||||
|
@ -46,7 +46,8 @@ _m_presence_eval
|
|||
};
|
||||
|
||||
void
|
||||
handle_edu_m_presence(const m::event &event)
|
||||
handle_edu_m_presence(const m::event &event,
|
||||
m::vm::eval &eval)
|
||||
try
|
||||
{
|
||||
if(m::my_host(at<"origin"_>(event)))
|
||||
|
|
|
@ -21,9 +21,9 @@ static void handle_m_receipt_m_read(const m::room::id &, const m::user::id &, co
|
|||
static void handle_m_receipt_m_read(const m::room::id &, const m::user::id &, const m::edu::m_receipt::m_read &);
|
||||
static void handle_m_receipt_m_read(const m::room::id &, const json::object &);
|
||||
static void handle_m_receipt(const m::room::id &, const json::object &);
|
||||
static void handle_edu_m_receipt(const m::event &);
|
||||
static void handle_edu_m_receipt(const m::event &, m::vm::eval &);
|
||||
|
||||
const m::hookfn<>
|
||||
const m::hookfn<m::vm::eval &>
|
||||
_m_receipt_eval
|
||||
{
|
||||
handle_edu_m_receipt,
|
||||
|
@ -34,7 +34,8 @@ _m_receipt_eval
|
|||
};
|
||||
|
||||
void
|
||||
handle_edu_m_receipt(const m::event &event)
|
||||
handle_edu_m_receipt(const m::event &event,
|
||||
m::vm::eval &eval)
|
||||
{
|
||||
if(json::get<"room_id"_>(event))
|
||||
return;
|
||||
|
|
|
@ -72,7 +72,8 @@ _changed_aliases_hookfn
|
|||
};
|
||||
|
||||
void
|
||||
_can_change_aliases(const m::event &event)
|
||||
_can_change_aliases(const m::event &event,
|
||||
m::vm::eval &eval)
|
||||
{
|
||||
const m::room::id &room_id
|
||||
{
|
||||
|
@ -97,7 +98,7 @@ _can_change_aliases(const m::event &event)
|
|||
}
|
||||
}
|
||||
|
||||
const m::hookfn<>
|
||||
const m::hookfn<m::vm::eval &>
|
||||
_can_change_aliases_hookfn
|
||||
{
|
||||
_can_change_aliases,
|
||||
|
|
|
@ -68,7 +68,8 @@ _changed_canonical_alias_hookfn
|
|||
};
|
||||
|
||||
void
|
||||
_can_change_canonical_alias(const m::event &event)
|
||||
_can_change_canonical_alias(const m::event &event,
|
||||
m::vm::eval &eval)
|
||||
{
|
||||
const m::room::id &room_id
|
||||
{
|
||||
|
@ -108,7 +109,7 @@ _can_change_canonical_alias(const m::event &event)
|
|||
};
|
||||
}
|
||||
|
||||
const m::hookfn<>
|
||||
const m::hookfn<m::vm::eval &>
|
||||
_can_change_canonical_alias_hookfn
|
||||
{
|
||||
_can_change_canonical_alias,
|
||||
|
|
|
@ -17,7 +17,8 @@ IRCD_MODULE
|
|||
};
|
||||
|
||||
static void
|
||||
_can_create_room(const m::event &event)
|
||||
_can_create_room(const m::event &event,
|
||||
m::vm::eval &eval)
|
||||
{
|
||||
const m::room::id &room_id
|
||||
{
|
||||
|
@ -36,7 +37,7 @@ _can_create_room(const m::event &event)
|
|||
};
|
||||
}
|
||||
|
||||
const m::hookfn<>
|
||||
const m::hookfn<m::vm::eval &>
|
||||
_can_create_room_hookfn
|
||||
{
|
||||
_can_create_room,
|
||||
|
|
|
@ -54,12 +54,13 @@ affect_user_room_hookfn
|
|||
};
|
||||
|
||||
static void
|
||||
_can_join_room(const m::event &event)
|
||||
_can_join_room(const m::event &event,
|
||||
m::vm::eval &eval)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const m::hookfn<>
|
||||
const m::hookfn<m::vm::eval &>
|
||||
_can_join_room_hookfn
|
||||
{
|
||||
{
|
||||
|
@ -95,7 +96,8 @@ invite__foreign
|
|||
};
|
||||
|
||||
static void
|
||||
invite_foreign(const m::event &event)
|
||||
invite_foreign(const m::event &event,
|
||||
m::vm::eval &eval)
|
||||
{
|
||||
const m::room::id &room_id
|
||||
{
|
||||
|
@ -127,7 +129,7 @@ invite_foreign(const m::event &event)
|
|||
|
||||
}
|
||||
|
||||
const m::hookfn<>
|
||||
const m::hookfn<m::vm::eval &>
|
||||
invite_foreign_hookfn
|
||||
{
|
||||
{
|
||||
|
|
|
@ -17,9 +17,9 @@ IRCD_MODULE
|
|||
};
|
||||
|
||||
static void _handle_edu_m_typing(const m::event &, const m::typing &edu);
|
||||
static void handle_edu_m_typing(const m::event &);
|
||||
static void handle_edu_m_typing(const m::event &, m::vm::eval &);
|
||||
|
||||
const m::hookfn<>
|
||||
const m::hookfn<m::vm::eval &>
|
||||
_m_typing_eval
|
||||
{
|
||||
handle_edu_m_typing,
|
||||
|
@ -30,7 +30,8 @@ _m_typing_eval
|
|||
};
|
||||
|
||||
void
|
||||
handle_edu_m_typing(const m::event &event)
|
||||
handle_edu_m_typing(const m::event &event,
|
||||
m::vm::eval &eval)
|
||||
{
|
||||
const json::object &content
|
||||
{
|
||||
|
|
|
@ -10,10 +10,11 @@
|
|||
|
||||
namespace ircd::m::vm
|
||||
{
|
||||
extern hook::site<> commit_hook;
|
||||
extern hook::site<eval &> fetch_hook;
|
||||
extern hook::site<> eval_hook;
|
||||
extern hook::site<> notify_hook;
|
||||
|
||||
extern hook::site<eval &> commit_hook; ///< Called when this server issues event
|
||||
extern hook::site<eval &> fetch_hook; ///< Called to resolve dependencies
|
||||
extern hook::site<eval &> eval_hook; ///< Called when evaluating event
|
||||
extern hook::site<> notify_hook; ///< Called after successful evaluation
|
||||
|
||||
static void write_commit(eval &);
|
||||
static fault _eval_edu(eval &, const event &);
|
||||
|
@ -439,7 +440,7 @@ try
|
|||
};
|
||||
|
||||
check_size(event);
|
||||
commit_hook(event);
|
||||
commit_hook(event, eval);
|
||||
}
|
||||
|
||||
const event::conforms &report
|
||||
|
@ -594,7 +595,7 @@ enum ircd::m::vm::fault
|
|||
ircd::m::vm::_eval_edu(eval &eval,
|
||||
const event &event)
|
||||
{
|
||||
eval_hook(event);
|
||||
eval_hook(event, eval);
|
||||
return fault::ACCEPT;
|
||||
}
|
||||
|
||||
|
@ -650,7 +651,7 @@ ircd::m::vm::_eval_pdu(eval &eval,
|
|||
fetch_hook(event, eval);
|
||||
|
||||
// Evaluation by module hooks
|
||||
eval_hook(event);
|
||||
eval_hook(event, eval);
|
||||
|
||||
if(!opts.write)
|
||||
return fault::ACCEPT;
|
||||
|
|
Loading…
Reference in a new issue