-
Notifications
You must be signed in to change notification settings - Fork 364
Description
Provide a way to access homeserver config in the Module API.
Use case
We have two modules where one provides room retention functionality and other provides API's to modify those room retention settings. We would like to read the module config of one module in the other module so that the API can respond with a default value if the setting hasn't been set in the database yet
Current state of things
Currently, you only have explicit access to your own modules config which is passed in the module constructor
Workaround
We're currently working around this by accessing the private/internal module_api._hs
field.
class MyModule:
def __init__(
self, config: MyModuleConfig, module_api: ModuleApi
):
# Access homeserver config
logger.info(module_api._hs.config)
# Access config of other modules
logger.info(module_api._hs.config.modules.loaded_modules)
Alternatives
We could have the room retention module itself expose an HTTP API to fetch the config which our other module can consume.
This might even be deemed the correct approach to all of this when we have two modules that can cooperate. Better separation of concerns.
Activity