Previous code was not checking/enforcing rule 4.3.1
(https://spec.matrix.org/v1.2/rooms/v9/), which states that a room
member event (with a join membership) must be accepted only if it contains
a previous event which `state_key` is the room creator.
On top of that, it simplifies the public interface for `auth_rules`,
removing the need of (externally) compute `prev_event`, which, as a side
effect, should reduce the amount of times the previous event needs to be
fetched: It will only load it if the authorized event is a `m.room_member`
with a `Join` state.
Finally, I've splitted the join conditions so it's (hopefully) more
readable and apply auth rules in the same order as they
appear in the spec.
Gets rid of unnecessary copying and makes things more explicit by using
a struct with named fields instead of a tuple for tie breaking.
Co-authored-by: Jonathan de Jong <jonathan@automatia.nl>
In a previous commit I moved the auth chain calculation code to ruma
because I thought I could optimize it by only taking auth chains from
conflicted events instead of all events. It turned out that was wrong
and now I removed that algorithm again (the full auth chains are now
passed in as an argument to state_res::resolve again).