mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-03 02:34:50 -04:00
Implement a Jinja2 filter to extract localparts from email addresses (#12212)
This commit is contained in:
parent
4a53f35737
commit
e6a106fd5e
6 changed files with 23 additions and 2 deletions
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue