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
Experimental support for MSC3970: per-device transaction IDs #15318
Merged
erikjohnston
merged 5 commits into
matrix-org:develop
from
sandhose:quenting/scope-txnids-to-deviceids
Apr 25, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c8b861a
Experimental support for MSC3970: per-device transaction IDs
sandhose 3dbca90
Implement MSC3970 in the HttpTransactionCache
sandhose afa0fc2
Newsfile.
sandhose fff4c64
Also lookup for existing events with the device_id in local membershi…
sandhose f56d6f4
Merge branch 'develop' into quenting/scope-txnids-to-deviceids
sandhose 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 @@ | ||
Experimental support for MSC3970: Scope transaction IDs to devices. | ||
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
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
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
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
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 |
---|---|---|
|
@@ -169,6 +169,8 @@ def __init__(self, hs: "HomeServer"): | |
self.request_ratelimiter = hs.get_request_ratelimiter() | ||
hs.get_notifier().add_new_join_in_room_callback(self._on_user_joined_room) | ||
|
||
self._msc3970_enabled = hs.config.experimental.msc3970_enabled | ||
|
||
def _on_user_joined_room(self, event_id: str, room_id: str) -> None: | ||
"""Notify the rate limiter that a room join has occurred. | ||
|
||
|
@@ -399,13 +401,30 @@ async def _local_membership_update( | |
# Check if we already have an event with a matching transaction ID. (We | ||
# do this check just before we persist an event as well, but may as well | ||
# do it up front for efficiency.) | ||
if txn_id and requester.access_token_id: | ||
existing_event_id = await self.store.get_event_id_from_transaction_id( | ||
room_id, | ||
requester.user.to_string(), | ||
requester.access_token_id, | ||
txn_id, | ||
) | ||
if txn_id: | ||
existing_event_id = None | ||
if self._msc3970_enabled and requester.device_id: | ||
# When MSC3970 is enabled, we lookup for events sent by the same device | ||
# first, and fallback to the old behaviour if none were found. | ||
existing_event_id = ( | ||
await self.store.get_event_id_from_transaction_id_and_device_id( | ||
room_id, | ||
requester.user.to_string(), | ||
requester.device_id, | ||
txn_id, | ||
) | ||
) | ||
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. Do we not also need to check the new table here? 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. Good catch, fixed it |
||
|
||
if requester.access_token_id and not existing_event_id: | ||
existing_event_id = ( | ||
await self.store.get_event_id_from_transaction_id_and_token_id( | ||
room_id, | ||
requester.user.to_string(), | ||
requester.access_token_id, | ||
txn_id, | ||
) | ||
) | ||
|
||
if existing_event_id: | ||
event_pos = await self.store.get_position_for_event(existing_event_id) | ||
return existing_event_id, event_pos.stream | ||
|
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
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
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
Oops, something went wrong.
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.
Since MSC3970 landed before this, should we just stabilize it so we never have to deal with a released version of the unstable version?