mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Factor out soft fail checks
This commit is contained in:
parent
4c473ba088
commit
0ff8163eae
@ -1847,6 +1847,28 @@ class FederationHandler(BaseHandler):
|
|||||||
|
|
||||||
context.rejected = RejectedReason.AUTH_ERROR
|
context.rejected = RejectedReason.AUTH_ERROR
|
||||||
|
|
||||||
|
if not context.rejected:
|
||||||
|
yield self._check_for_soft_fail(event, state, backfilled)
|
||||||
|
|
||||||
|
if event.type == EventTypes.GuestAccess and not context.rejected:
|
||||||
|
yield self.maybe_kick_guest_users(event)
|
||||||
|
|
||||||
|
defer.returnValue(context)
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def _check_for_soft_fail(self, event, state, backfilled):
|
||||||
|
"""Checks if we should soft fail the event, if so marks the event as
|
||||||
|
such.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
event (FrozenEvent)
|
||||||
|
state (dict|None): The state at the event if we don't have all the
|
||||||
|
event's prev events
|
||||||
|
backfilled (bool): Whether the event is from backfill
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Deferred
|
||||||
|
"""
|
||||||
# For new (non-backfilled and non-outlier) events we check if the event
|
# For new (non-backfilled and non-outlier) events we check if the event
|
||||||
# passes auth based on the current state. If it doesn't then we
|
# passes auth based on the current state. If it doesn't then we
|
||||||
# "soft-fail" the event.
|
# "soft-fail" the event.
|
||||||
@ -1918,11 +1940,6 @@ class FederationHandler(BaseHandler):
|
|||||||
)
|
)
|
||||||
event.internal_metadata.soft_failed = True
|
event.internal_metadata.soft_failed = True
|
||||||
|
|
||||||
if event.type == EventTypes.GuestAccess and not context.rejected:
|
|
||||||
yield self.maybe_kick_guest_users(event)
|
|
||||||
|
|
||||||
defer.returnValue(context)
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def on_query_auth(self, origin, event_id, room_id, remote_auth_chain, rejects,
|
def on_query_auth(self, origin, event_id, room_id, remote_auth_chain, rejects,
|
||||||
missing):
|
missing):
|
||||||
|
Loading…
Reference in New Issue
Block a user