Skip to content

Module API: Provide a way to access homeserver config #18340

@MadLittleMods

Description

@MadLittleMods
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @MadLittleMods

        Issue actions

          Module API: Provide a way to access homeserver config · Issue #18340 · element-hq/synapse