0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

ircd:Ⓜ️:vm: Add options for pre-checked event conformity or skip entirely.

This commit is contained in:
Jason Volk 2018-03-12 19:34:54 -07:00
parent 9749d7c609
commit 4aaeaff8fb
2 changed files with 19 additions and 4 deletions

View file

@ -95,9 +95,21 @@ struct ircd::m::vm::opts
/// Broadcast to clients/servers
bool notify {true};
/// Mask of conformity failures to allow without error
/// False to allow a dirty conforms report (not recommended).
bool conforming {true};
/// Mask of conformity failures to allow without considering dirty.
event::conforms non_conform;
/// If the event was already checked before the eval, set this to true
/// and include the report (see below).
bool conformed {false};
/// When conformed=true, this report will be included instead of generating
/// one during the eval. This is useful if a conformity check was already
/// done before eval.
event::conforms report;
/// Toggles whether event may be considered a "present event" and may
/// update the optimized present state table of the room if it is proper.
bool present {true};

View file

@ -209,12 +209,15 @@ enum ircd::m::vm::fault
ircd::m::vm::eval::operator()(const event &event)
try
{
const event::conforms report
assert(opts);
const event::conforms &report
{
event, opts->non_conform.report
opts->conforming && !opts->conformed?
event::conforms{event, opts->non_conform.report}:
opts->report
};
if(!report.clean())
if(opts->conforming && !report.clean())
throw error
{
fault::INVALID, "Non-conforming event: %s", string(report)