Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Allow modules to retrieve server and worker names (#11868)
Browse files Browse the repository at this point in the history
Fixes #10701
  • Loading branch information
babolivier authored Feb 1, 2022
1 parent 64ec45f commit 5c16c33
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/11868.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow modules to retrieve the current instance's server name and worker name.
26 changes: 26 additions & 0 deletions synapse/module_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,32 @@ def email_app_name(self) -> str:
"""
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
Expand Down

0 comments on commit 5c16c33

Please sign in to comment.