summary refs log tree commit diff
path: root/synapse/util/templates.py
diff options
context:
space:
mode:
authorBrendan Abolivier <babolivier@matrix.org>2022-03-11 16:15:11 +0100
committerGitHub <noreply@github.com>2022-03-11 15:15:11 +0000
commite6a106fd5ebbf30a7c84f8ba09dc903d20213be3 (patch)
treeef6a140878f1fa7903842f943da01fa2e40fc0a8 /synapse/util/templates.py
parentImprove code documentation for the typing stream over replication. (#12211) (diff)
downloadsynapse-e6a106fd5ebbf30a7c84f8ba09dc903d20213be3.tar.xz
Implement a Jinja2 filter to extract localparts from email addresses (#12212)
Diffstat (limited to '')
-rw-r--r--synapse/util/templates.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/synapse/util/templates.py b/synapse/util/templates.py
index 12941065ca..fb758b7180 100644
--- a/synapse/util/templates.py
+++ b/synapse/util/templates.py
@@ -64,6 +64,7 @@ def build_jinja_env(
         {
             "format_ts": _format_ts_filter,
             "mxc_to_http": _create_mxc_to_http_filter(config.server.public_baseurl),
+            "localpart_from_email": _localpart_from_email_filter,
         }
     )
 
@@ -112,3 +113,7 @@ def _create_mxc_to_http_filter(
 
 def _format_ts_filter(value: int, format: str) -> str:
     return time.strftime(format, time.localtime(value / 1000))
+
+
+def _localpart_from_email_filter(address: str) -> str:
+    return address.rsplit("@", 1)[0]