This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Hoist cache_joined_hosts_for_event
to caller
#10986
Merged
richvdh
merged 1 commit into
develop
from
rav/unpick_update_auth_events_and_context_for_auth/12_hoist_warm_joined_cache
Oct 5, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Clean up some of the federation event authentication code for clarity. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -356,6 +356,11 @@ async def on_send_membership_event( | |
) | ||
|
||
# all looks good, we can persist the event. | ||
|
||
# First, precalculate the joined hosts so that the federation sender doesn't | ||
# need to. | ||
await self._event_creation_handler.cache_joined_hosts_for_event(event, context) | ||
|
||
await self._run_push_actions_and_persist_event(event, context) | ||
return event, context | ||
|
||
|
@@ -1291,17 +1296,10 @@ async def _check_event_auth( | |
except AuthError as e: | ||
logger.warning("Failed auth resolution for %r because %s", event, e) | ||
context.rejected = RejectedReason.AUTH_ERROR | ||
return context | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nowhere else in this method sets |
||
|
||
if not context.rejected: | ||
await self._check_for_soft_fail(event, state, backfilled, origin=origin) | ||
await self._maybe_kick_guest_users(event) | ||
|
||
# If we are going to send this event over federation we precaclculate | ||
# the joined hosts. | ||
if event.internal_metadata.get_send_on_behalf_of(): | ||
await self._event_creation_handler.cache_joined_hosts_for_event( | ||
event, context | ||
) | ||
await self._check_for_soft_fail(event, state, backfilled, origin=origin) | ||
await self._maybe_kick_guest_users(event) | ||
|
||
return context | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously we would do this even if
context.rejected
was truth-y. I suspect that wasn't helpful since the event is rejected, but wanted to point this out as a change in behavior.Also, I find the comment a bit odd "fIrst...", but there's no follow-up (no "then" / "next" / "second"). 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it's deliberate, but I think the only difference is that we won't be populating a cache entry that will never be used.
mmhmm. it's in reference to the line above: "we can persist the event ... But first, precalculate the joined hosts".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair! Not a huge deal, just felt like I was left with a cliffhanger!