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
Preparatory work to fix the user directory assuming that any remote membership state events represent a profile change. [rei:userdirpriv] #14755
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
89c40db
Remove special-case method for new memberships only, use more generic…
reivilibre 1198bee
Only collect profiles from state events in public rooms
reivilibre 3257912
Add a table to track stale remote user profiles
reivilibre 331969c
Add store methods to set and delete rows in this new table
reivilibre ab3b191
Mark remote profiles as stale when a member state event comes in to a…
reivilibre 327bcef
Newsfile
reivilibre 5a543d6
Simplify by removing Optionality of `event_id`
reivilibre 2185fc4
Merge branch 'develop' into rei/userdirpriv1_collect_public_only
reivilibre 7966973
Replace names and avatars with None if they're set to dodgy things
reivilibre 2e52bf9
Move schema delta to 74 (I missed the boat?)
reivilibre 3280675
Turns out these can be None after all
reivilibre db1d75b
Merge branch 'develop' into rei/userdirpriv1_collect_public_only
reivilibre 5aefde4
Merge branch 'develop' into rei/userdirpriv1_collect_public_only
reivilibre 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 @@ | ||
Fix a long-standing bug in which the user directory would assume any remote membership state events represent a profile change. |
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
39 changes: 39 additions & 0 deletions
39
synapse/storage/schema/main/delta/74/01_user_directory_stale_remote_users.sql
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,39 @@ | ||
/* Copyright 2022 The Matrix.org Foundation C.I.C | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
-- Table containing a list of remote users whose profiles may have changed | ||
-- since their last update in the user directory. | ||
CREATE TABLE user_directory_stale_remote_users ( | ||
-- The User ID of the remote user whose profile may be stale. | ||
user_id TEXT NOT NULL PRIMARY KEY, | ||
|
||
-- The server name of the user. | ||
user_server_name TEXT NOT NULL, | ||
|
||
-- The timestamp (in ms) after which we should next try to request the user's | ||
-- latest profile. | ||
next_try_at_ts BIGINT NOT NULL, | ||
|
||
-- The number of retries so far. | ||
-- 0 means we have not yet attempted to refresh the profile. | ||
-- Used for calculating exponential backoff. | ||
retry_counter INTEGER NOT NULL | ||
); | ||
|
||
-- Create an index so we can easily query upcoming servers to try. | ||
CREATE INDEX user_directory_stale_remote_users_next_try_idx ON user_directory_stale_remote_users(next_try_at_ts, user_server_name); | ||
|
||
-- Create an index so we can easily query upcoming users to try for a particular server. | ||
CREATE INDEX user_directory_stale_remote_users_next_try_by_server_idx ON user_directory_stale_remote_users(user_server_name, next_try_at_ts); |
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.
When there is no prev event, we can now try to update the user directory with non-strings, despite the type checks above.
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.
Hm this was already flawed by the looks: you could just send a dodgy event and then follow it up with another dodgy event to get the
prev_event
accepted.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.
But
update_profile_in_user_dir
sets it to None if you pass in a non-string, so I suggest we just replace non-strings with None anyway.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.
That approach sounds reasonable!