diff options
author | Olivier Wilkinson (reivilibre) <oliverw@matrix.org> | 2023-02-17 17:41:19 +0000 |
---|---|---|
committer | Olivier Wilkinson (reivilibre) <oliverw@matrix.org> | 2023-03-16 11:45:14 +0000 |
commit | 1552fa44dbb8ab43f0c13a06b512625851d9f919 (patch) | |
tree | 0a21a9caa10ce4aabe9fbb3b2ab012e9fc34ffe1 /synapse | |
parent | Add a background update stage to sort the remote users into the stale profile... (diff) | |
download | synapse-1552fa44dbb8ab43f0c13a06b512625851d9f919.tar.xz |
(ugly?) Kick off the fetching of remote profiles once ready
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/replication/tcp/commands.py | 18 | ||||
-rw-r--r-- | synapse/storage/databases/main/user_directory.py | 14 |
2 files changed, 32 insertions, 0 deletions
diff --git a/synapse/replication/tcp/commands.py b/synapse/replication/tcp/commands.py index 32f52e54d8..df229fc0a3 100644 --- a/synapse/replication/tcp/commands.py +++ b/synapse/replication/tcp/commands.py @@ -422,6 +422,21 @@ class RemoteServerUpCommand(_SimpleCommand): NAME = "REMOTE_SERVER_UP" +class ReadyToRefreshStaleUserDirectoryProfilesCommand(_SimpleCommand): + """ + Sent when a worker needs to tell the user directory worker that there are + stale remote user profiles that require refreshing. + + Triggered when the user directory background update has been completed. + + Format:: + + USER_DIRECTORY_READY_TO_REFRESH_STALE_REMOTE_PROFILES '' + """ + + NAME = "USER_DIRECTORY_READY_TO_REFRESH_STALE_REMOTE_PROFILES" + + _COMMANDS: Tuple[Type[Command], ...] = ( ServerCommand, RdataCommand, @@ -435,6 +450,7 @@ _COMMANDS: Tuple[Type[Command], ...] = ( UserIpCommand, RemoteServerUpCommand, ClearUserSyncsCommand, + ReadyToRefreshStaleUserDirectoryProfilesCommand, ) # Map of command name to command type. @@ -448,6 +464,7 @@ VALID_SERVER_COMMANDS = ( ErrorCommand.NAME, PingCommand.NAME, RemoteServerUpCommand.NAME, + ReadyToRefreshStaleUserDirectoryProfilesCommand.NAME, ) # The commands the client is allowed to send @@ -461,6 +478,7 @@ VALID_CLIENT_COMMANDS = ( UserIpCommand.NAME, ErrorCommand.NAME, RemoteServerUpCommand.NAME, + ReadyToRefreshStaleUserDirectoryProfilesCommand.NAME, ) diff --git a/synapse/storage/databases/main/user_directory.py b/synapse/storage/databases/main/user_directory.py index 1beb01cd77..b94b45a5b0 100644 --- a/synapse/storage/databases/main/user_directory.py +++ b/synapse/storage/databases/main/user_directory.py @@ -27,6 +27,10 @@ from typing import ( cast, ) +from synapse.replication.tcp.commands import ( + ReadyToRefreshStaleUserDirectoryProfilesCommand, +) + try: # Figure out if ICU support is available for searching users. import icu @@ -535,6 +539,16 @@ class UserDirectoryBackgroundUpdateStore(StateDeltasStore): await self.db_pool.updates._end_background_update( "populate_user_directory_process_remote_users" ) + + # Now kick off querying remote homeservers for profile information. + if self.hs.config.worker.should_update_user_directory: + self.hs.get_user_directory_handler().kick_off_remote_profile_refresh_process() + else: + command_handler = self.hs.get_replication_command_handler() + command_handler.send_command( + ReadyToRefreshStaleUserDirectoryProfilesCommand("") + ) + return 1 await self.db_pool.runInteraction( |