mirror of
https://github.com/matrix-construct/construct
synced 2025-02-19 18:20:19 +01:00
ircd:Ⓜ️:event::conforms: Add checks for m.room.member state_key.
This commit is contained in:
parent
7117d4a17c
commit
74fdda36e2
2 changed files with 12 additions and 0 deletions
|
@ -62,6 +62,8 @@ enum ircd::m::event::conforms::code
|
|||
INVALID_OR_MISSING_REDACTS_ID, ///< for m.room.redaction
|
||||
MISSING_CONTENT_MEMBERSHIP, ///< for m.room.member, content.membership
|
||||
INVALID_CONTENT_MEMBERSHIP, ///< for m.room.member, content.membership
|
||||
MISSING_MEMBER_STATE_KEY, ///< for m.room.member, !empty(state_key)
|
||||
INVALID_MEMBER_STATE_KEY, ///< for m.room.member, !user::id(state_key)
|
||||
MISSING_PREV_EVENTS, ///< for non-m.room.create, empty prev_events
|
||||
MISSING_PREV_STATE, ///< for state_key'ed, empty prev_state
|
||||
MISSING_AUTH_EVENTS, ///< for non-m.room.create, empty auth_events
|
||||
|
|
|
@ -166,6 +166,8 @@ ircd::m::event_conforms_reflects
|
|||
"INVALID_OR_MISSING_REDACTS_ID",
|
||||
"MISSING_CONTENT_MEMBERSHIP",
|
||||
"INVALID_CONTENT_MEMBERSHIP",
|
||||
"MISSING_MEMBER_STATE_KEY",
|
||||
"INVALID_MEMBER_STATE_KEY",
|
||||
"MISSING_PREV_EVENTS",
|
||||
"MISSING_PREV_STATE",
|
||||
"MISSING_AUTH_EVENTS",
|
||||
|
@ -289,6 +291,14 @@ ircd::m::event::conforms::conforms(const event &e)
|
|||
if(!all_of<std::islower>(unquote(json::get<"content"_>(e).get("membership"))))
|
||||
set(INVALID_CONTENT_MEMBERSHIP);
|
||||
|
||||
if(json::get<"type"_>(e) == "m.room.member")
|
||||
if(empty(json::get<"state_key"_>(e)))
|
||||
set(MISSING_MEMBER_STATE_KEY);
|
||||
|
||||
if(json::get<"type"_>(e) == "m.room.member")
|
||||
if(!valid(m::id::USER, json::get<"state_key"_>(e)))
|
||||
set(INVALID_MEMBER_STATE_KEY);
|
||||
|
||||
if(json::get<"type"_>(e) != "m.room.create")
|
||||
if(empty(json::get<"prev_events"_>(e)))
|
||||
set(MISSING_PREV_EVENTS);
|
||||
|
|
Loading…
Add table
Reference in a new issue