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

Use the default templates when a custom template file cannot be found #8037

Merged
merged 41 commits into from
Aug 17, 2020

Commits on Aug 5, 2020

  1. Remove conditional requirement for already required Jinja2

    Not sure if we need to keep the conditional requirement name though...
    anoadragon453 committed Aug 5, 2020
    Configuration menu
    Copy the full SHA
    3d4f917 View commit details
    Browse the repository at this point in the history

Commits on Aug 6, 2020

  1. Create a generic function to read jinja2 templates

    Create a generic function to read template files, which are also treated as
    jinja2 templates whether they have any custom variables or not. The goal is
    for this function to be used across the codebase. At the moment it is
    located in emailconfig.py, but I'd like to move it to another config file
    at some point along with the rest of the template options.
    anoadragon453 committed Aug 6, 2020
    Configuration menu
    Copy the full SHA
    0046454 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4ace21a View commit details
    Browse the repository at this point in the history
  3. Change create_mxc_to_http_filter to public function

    We'll be using it in other files in subsequent commits
    anoadragon453 committed Aug 6, 2020
    Configuration menu
    Copy the full SHA
    e3c75b1 View commit details
    Browse the repository at this point in the history
  4. Update synapse/push/pusher.py to use read_templates

    jinja2 and bleach are no longer optional dependencies.
    anoadragon453 committed Aug 6, 2020
    Configuration menu
    Copy the full SHA
    dd81441 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    15f5aa0 View commit details
    Browse the repository at this point in the history
  6. Convert synapse/handlers/account_validity.py to use read_templates

    Also remove guard on importing load_jinja2_templates here
    anoadragon453 committed Aug 6, 2020
    Configuration menu
    Copy the full SHA
    6f9e4b0 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    e1ba6be View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    44dc4aa View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    c8f105b View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    e8799e8 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    2d442bf View commit details
    Browse the repository at this point in the history
  12. Add a test

    anoadragon453 committed Aug 6, 2020
    Configuration menu
    Copy the full SHA
    7034971 View commit details
    Browse the repository at this point in the history
  13. Changelog

    anoadragon453 committed Aug 6, 2020
    Configuration menu
    Copy the full SHA
    00f4f63 View commit details
    Browse the repository at this point in the history

Commits on Aug 14, 2020

  1. Merge branch 'develop' of github.com:matrix-org/synapse into anoa/def…

    …ault_templates
    
    * 'develop' of github.com:matrix-org/synapse: (57 commits)
      Remove a space at the start of a changelog entry.
      More changelog tweaks
      More changelog tweaks
      Remove unwanted changelog line
      1.19.0rc1
      Run `remove_push_actions_from_staging` in foreground (#8081)
      Drop federation transmission queues during a significant remote outage. (#7864)
      Fix unawaited coroutine error in tests. (#8072)
      Convert the roommember database to async/await. (#8070)
      Convert devices database to async/await. (#8069)
      Add type hints to handlers.message and events.builder (#8067)
      Convert account data, device inbox, and censor events databases to async/await (#8063)
      Convert appservice, group server, profile and more databases to async (#8066)
      Fix typing for notifier (#8064)
      Convert tags and metrics databases to async/await (#8062)
      Converts event_federation and registration databases to async/await (#8061)
      Add comment explaining cast
      Update changelog.d/8051.misc
      Add typing info to Notifier (#8058)
      Handle optional dependencies for Oidc and Saml
      ...
    anoadragon453 committed Aug 14, 2020
    Configuration menu
    Copy the full SHA
    2e7de8d View commit details
    Browse the repository at this point in the history
  2. sample config

    anoadragon453 committed Aug 14, 2020
    Configuration menu
    Copy the full SHA
    7b674bf View commit details
    Browse the repository at this point in the history
  3. Simplify template loading code

    Turns out jinja2.FilesystemLoader can take a list of directories to look for
    a given filename in, so there's no need to check for the file ourselves.
    
    We also now reuse the jinja2.Environment object
    anoadragon453 committed Aug 14, 2020
    Configuration menu
    Copy the full SHA
    57c64c4 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    93555f4 View commit details
    Browse the repository at this point in the history
  5. Remove extra comma

    anoadragon453 committed Aug 14, 2020
    Configuration menu
    Copy the full SHA
    ab3f058 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    bcb04ad View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    c77608c View commit details
    Browse the repository at this point in the history
  8. Add docstring and improve create_mxc_to_http_filter

    The urllib -> urllib.parse switch was because we use urllib.parse in the code
    which afaik only works because we're importing urlib.parse elsewhere, which
    is flakey
    anoadragon453 committed Aug 14, 2020
    Configuration menu
    Copy the full SHA
    bf79f9e View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    49dbd26 View commit details
    Browse the repository at this point in the history
  10. misc -> feature

    anoadragon453 committed Aug 14, 2020
    Configuration menu
    Copy the full SHA
    1dfca15 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    45d6e4c View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    de41b66 View commit details
    Browse the repository at this point in the history
  13. Raise ConfigError if custom template directory does not exist

    So that people are warned early that their assumed custom
    template directory is in fact doing nothing
    anoadragon453 committed Aug 14, 2020
    Configuration menu
    Copy the full SHA
    e7ca492 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    c81cdb6 View commit details
    Browse the repository at this point in the history

Commits on Aug 17, 2020

  1. Switch all read_templates calls from handlers to synapse.config

    Lots of general cleanup of the template code in emailconfig.
    
    The account_validity config option bit was that I noticed what we were
    pulling out of the config had been done elsewhere already.
    
    Also move filter functions from synapse.push.mailer to synapse.config._base
    as otherwise we were facing circular imports (plus it makes sense to keep them by
    read_templates anyhow).
    anoadragon453 committed Aug 17, 2020
    Configuration menu
    Copy the full SHA
    87fea4c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7660398 View commit details
    Browse the repository at this point in the history
  3. Use custom filters on all templates

    The performance difference is negligible and cleans up some duplicate code.
    anoadragon453 committed Aug 17, 2020
    Configuration menu
    Copy the full SHA
    d9d8d72 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    405db9a View commit details
    Browse the repository at this point in the history
  5. Only abspath the template_dir if it's set

    Otherwise a TypeError will be raised if template_dir is uncommented
    but not set to anything
    
    Additionally remove default_template_dir here as read_templates
    handles that for us.
    anoadragon453 committed Aug 17, 2020
    Configuration menu
    Copy the full SHA
    93b71d8 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    a1d7d9c View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    94300cc View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    f08b610 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    7b943e6 View commit details
    Browse the repository at this point in the history
  10. Apply self.config suggestions

    Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
    anoadragon453 and clokep authored Aug 17, 2020
    Configuration menu
    Copy the full SHA
    5806a08 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    c654916 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    d35c049 View commit details
    Browse the repository at this point in the history
  13. Render sso deactived/success templates

    We switched from reading them directly from disk to making them
    into jinja2.Template files, which broke stuff. We now render
    them to turn them back into text.
    anoadragon453 committed Aug 17, 2020
    Configuration menu
    Copy the full SHA
    116a895 View commit details
    Browse the repository at this point in the history