Allow modules to retrieve server and worker names (#11868)

Fixes #10701
This commit is contained in:
Brendan Abolivier 2022-02-01 16:23:55 +01:00 committed by GitHub
parent 64ec45fc1b
commit 5c16c33021
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1 @@
Allow modules to retrieve the current instance's server name and worker name.

View File

@ -401,6 +401,32 @@ class ModuleApi:
"""
return self._hs.config.email.email_app_name
@property
def server_name(self) -> str:
"""The server name for the local homeserver.
Added in Synapse v1.53.0.
"""
return self._server_name
@property
def worker_name(self) -> Optional[str]:
"""The name of the worker this specific instance is running as per the
"worker_name" configuration setting, or None if it's the main process.
Added in Synapse v1.53.0.
"""
return self._hs.config.worker.worker_name
@property
def worker_app(self) -> Optional[str]:
"""The name of the worker app this specific instance is running as per the
"worker_app" configuration setting, or None if it's the main process.
Added in Synapse v1.53.0.
"""
return self._hs.config.worker.worker_app
async def get_userinfo_by_id(self, user_id: str) -> Optional[UserInfo]:
"""Get user info by user_id