mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +01:00
ircd:Ⓜ️:vm: Minor cleanup; move branch; comments.
This commit is contained in:
parent
cf065aedbe
commit
f5fe4c7566
1 changed files with 22 additions and 9 deletions
|
@ -247,11 +247,16 @@ try
|
||||||
const scope_restore eval_room_id
|
const scope_restore eval_room_id
|
||||||
{
|
{
|
||||||
eval.room_id,
|
eval.room_id,
|
||||||
|
|
||||||
|
// Retain any predetermined room_id.
|
||||||
eval.room_id?
|
eval.room_id?
|
||||||
eval.room_id:
|
eval.room_id:
|
||||||
valid(id::ROOM, json::get<"room_id"_>(event))?
|
|
||||||
|
// Use the room_id in the event
|
||||||
|
likely(valid(id::ROOM, json::get<"room_id"_>(event)))?
|
||||||
string_view(json::get<"room_id"_>(event)):
|
string_view(json::get<"room_id"_>(event)):
|
||||||
eval.room_id,
|
|
||||||
|
eval.room_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Determine if this is an internal room creation event
|
// Determine if this is an internal room creation event
|
||||||
|
@ -266,13 +271,21 @@ try
|
||||||
const scope_restore room_internal
|
const scope_restore room_internal
|
||||||
{
|
{
|
||||||
eval.room_internal,
|
eval.room_internal,
|
||||||
|
|
||||||
|
// Retain any existing true value from predetermination.
|
||||||
eval.room_internal?
|
eval.room_internal?
|
||||||
eval.room_internal:
|
eval.room_internal:
|
||||||
|
|
||||||
|
// Case for creating an internal room (as a query will fail)
|
||||||
is_internal_room_create?
|
is_internal_room_create?
|
||||||
true:
|
true:
|
||||||
|
|
||||||
|
// Query to find out if internal room.
|
||||||
eval.room_id && my(room::id(eval.room_id))?
|
eval.room_id && my(room::id(eval.room_id))?
|
||||||
m::internal(eval.room_id):
|
m::internal(eval.room_id):
|
||||||
false
|
|
||||||
|
// Default to false
|
||||||
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
// Procure the room version.
|
// Procure the room version.
|
||||||
|
@ -629,6 +642,12 @@ ircd::m::vm::execute_pdu(eval &eval,
|
||||||
opts.auth && !eval.room_internal
|
opts.auth && !eval.room_internal
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if(unlikely(eval.room_internal && !my(event)))
|
||||||
|
throw error
|
||||||
|
{
|
||||||
|
fault::GENERAL, "Internal room event denied from external source."
|
||||||
|
};
|
||||||
|
|
||||||
// The conform hook runs static checks on an event's formatting and
|
// The conform hook runs static checks on an event's formatting and
|
||||||
// composure; these checks only require the event data itself.
|
// composure; these checks only require the event data itself.
|
||||||
if(likely(opts.phase[phase::CONFORM]))
|
if(likely(opts.phase[phase::CONFORM]))
|
||||||
|
@ -642,12 +661,6 @@ ircd::m::vm::execute_pdu(eval &eval,
|
||||||
call_hook(conform_hook, eval, event, eval);
|
call_hook(conform_hook, eval, event, eval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(eval.room_internal && !my(event))
|
|
||||||
throw error
|
|
||||||
{
|
|
||||||
fault::GENERAL, "Internal room event denied from external source."
|
|
||||||
};
|
|
||||||
|
|
||||||
// Wait for any pending duplicate evals before proceeding.
|
// Wait for any pending duplicate evals before proceeding.
|
||||||
assert(eval::count(event_id));
|
assert(eval::count(event_id));
|
||||||
if(likely(opts.phase[phase::DUPCHK] && opts.unique))
|
if(likely(opts.phase[phase::DUPCHK] && opts.unique))
|
||||||
|
|
Loading…
Reference in a new issue