Skip to main content

iterative_auth_check

Function iterative_auth_check 

Source
pub(super) async fn iterative_auth_check<'b, SortedPowerEvents, Fetch, Fut, Pdu>(
    rules: &RoomVersionRules,
    events: SortedPowerEvents,
    state: StateMap<OwnedEventId>,
    fetch: &Fetch,
) -> Result<StateMap<OwnedEventId>>
where SortedPowerEvents: Stream<Item = &'b EventId> + Send, Fetch: Fn(OwnedEventId) -> Fut + Sync, Fut: Future<Output = Result<Pdu>> + Send, Pdu: Event,
Expand description

Perform the iterative auth checks to the given list of events.

Definition in the specification:

The iterative auth checks algorithm takes as input an initial room state and a sorted list of state events, and constructs a new room state by iterating through the event list and applying the state event to the room state if the state event is allowed by the authorization rules. If the state event is not allowed by the authorization rules, then the event is ignored. If a (event_type, state_key) key that is required for checking the authorization rules is not present in the state, then the appropriate state event from the event’s auth_events is used if the auth event is not rejected.

§Arguments

  • rules - The authorization rules for the current room version.
  • events - The sorted state events to apply to the partial_state.
  • state - The current state that was partially resolved for the room.
  • fetch_event - Function to fetch an event in the room given its event ID.

§Returns

Returns the partially resolved state, or an Err(_) if one of the state events in the room has an unexpected format.