From 79eed853977d0988fa4d99e91018412b5279c423 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 9 Mar 2019 12:08:05 -0800 Subject: [PATCH] modules/vm: Add a post-write pre-notify hook site. --- include/ircd/m/vm.h | 13 ++++++++----- modules/vm.cc | 20 +++++++++++++++----- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/ircd/m/vm.h b/include/ircd/m/vm.h index 0d7ace705..a2e83896b 100644 --- a/include/ircd/m/vm.h +++ b/include/ircd/m/vm.h @@ -113,17 +113,17 @@ enum ircd::m::vm::fault /// Evaluation Options struct ircd::m::vm::opts { - /// Make writes to database - bool write {true}; - /// Make fetches or false to bypass fetch stage. bool fetch {true}; /// Call eval hooks or false to bypass this stage. bool eval {true}; - /// Apply effects of this event or false to bypass this stage. - bool effects {true}; + /// Make writes to database + bool write {true}; + + /// Call post hooks or false to bypass post-write / pre-notify effects. + bool post {true}; /// Broadcast to clients/servers. When true, individual notify options /// that follow are considered. When false, no notifications occur. @@ -135,6 +135,9 @@ struct ircd::m::vm::opts /// Broadcast to federation servers (/federation/send/). bool notify_servers {true}; + /// Apply effects of this event or false to bypass this stage. + bool effects {true}; + /// False to allow a dirty conforms report (not recommended). bool conforming {true}; diff --git a/modules/vm.cc b/modules/vm.cc index ec307849d..925c21584 100644 --- a/modules/vm.cc +++ b/modules/vm.cc @@ -25,11 +25,12 @@ namespace ircd::m::vm static void init(); static void fini(); - extern hook::site commit_hook; ///< Called when this server issues event - extern hook::site fetch_hook; ///< Called to resolve dependencies - extern hook::site eval_hook; ///< Called when evaluating event - extern hook::site notify_hook; ///< Called to broadcast successful eval - extern hook::site effect_hook; ///< Called to apply effects of eval + extern hook::site commit_hook; ///< Called when this server issues event + extern hook::site fetch_hook; ///< Called to resolve dependencies + extern hook::site eval_hook; ///< Called when evaluating event + extern hook::site post_hook; ///< Called to apply effects pre-notify + extern hook::site notify_hook; ///< Called to broadcast successful eval + extern hook::site effect_hook; ///< Called to apply effects post-notify extern conf::item log_accept_debug; extern conf::item log_accept_info; @@ -74,6 +75,12 @@ ircd::m::vm::eval_hook { "name", "vm.eval" } }; +decltype(ircd::m::vm::post_hook) +ircd::m::vm::post_hook +{ + { "name", "vm.post" } +}; + decltype(ircd::m::vm::notify_hook) ircd::m::vm::notify_hook { @@ -491,6 +498,9 @@ try if(ret != fault::ACCEPT) return ret; + if(opts.post) + post_hook(event, eval); + if(opts.notify) notify_hook(event, eval);