matrix-docker-ansible-deploy icon indicating copy to clipboard operation
matrix-docker-ansible-deploy copied to clipboard

hint in synapse docs how to customize web/mail templates with matrix-aux

Open HarHarLinks opened this issue 3 years ago • 1 comments

With matrix-aux, custom files and directories can be created on the server. This is sufficient to facilitate customized web and mail templates for synapse (e.g. password reset email body).

It should be explained how to do that in the documentation of the synapse role and other places where applicable.

For an example of my case, see below.


original issue:

I would like to supply custom templates: https://matrix-org.github.io/synapse/latest/templates.html

I don't see a way to do this via the playbook, not even matrix_synapse_configuration_extension_yaml since these need to be files in certain directories which synapse will search for them. The custom_templates_directory can be customized and thus integrated into the docker mount command easily.

I would like to have variables for each of the templates like matrix_synapse_template_password_reset_html which is non-empty, will become password_reset.html in the custom_templates_directory.

Since these templates themselves may use jinja2, special care needs to be taken. Further care is necessary to allow empty lines for formatting of plain txt files.

As a workaround I have set custom_templates_directory to /data, to which /matrix/synapse/config gets mounted, and placed my files there manually.

HarHarLinks avatar Jan 13 '22 18:01 HarHarLinks

Right now, you can use the matrix-aux command to manage file creation on the server.

You can then use the matrix_synapse_container_additional_volumes variable to mount those files into the Synapse container, and matrix_synapse_configuration_extension_yaml to adjust the configuration.

spantaleev avatar Jan 13 '22 18:01 spantaleev

is this obsoleted by 5df89a44b386cfba65310742e3e2f4f6bd0cd6fe / https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/configuring-playbook-synapse.md#customizing-templates?

from what I understand not quite, imo it's a bit nicer to just mount these files instead of rebuilding the whole container?

HarHarLinks avatar Feb 18 '23 16:02 HarHarLinks

matrix-aux is still a good way to drop any custom files onto the server, for any reason (Synapse customization or other).

The new addition is very Synapse-specific, it only works for "templates" and is very opinionated in how it does it. So.. matrix-aux is not obsoleted by any means.

I suppose this issue can be closed though? Feel free to submit a PR improving the docs about the new Synapse customization feature or to mention matrix-aux and point people to its defaults/main.yml file which contains more information. I don't believe we have a dedicated matrix-aux documentation page.

spantaleev avatar Feb 18 '23 16:02 spantaleev

So I want this feature to remind my users who reset their passwords how to log in. I ended up doing something like this per your original suggestion:

matrix_aux_file_definitions:
  - dest: "{{ matrix_synapse_config_dir_path }}/password_reset.html"
    content: |
      <html>
      <body>
          <p>A password reset request has been received for your Matrix account. If this was you, please click the link below to confirm resetting your password:</p>
          <a href="{{ '{{' }} link {{ '}}' }}">{{ '{{' }} link {{ '}}' }}</a>
          [snip]
          [instructions about clients etc]
      </body>
      </html>
  - dest: "{{ matrix_synapse_config_dir_path }}/password_reset.txt"
    content: |
      [snip]
  - dest: "{{ matrix_synapse_config_dir_path }}/password_reset_success.html"
    content: |
      [snip]

and

matrix_synapse_configuration_extension_yaml: |
  templates:
    custom_template_directory: /data/

I think we could drop this as an example into a new matrix-aux docs page and mention in the new section of the synapse docs this alternative.

HarHarLinks avatar Feb 18 '23 21:02 HarHarLinks