diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2023-09-11 09:49:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-11 09:49:48 -0400 |
commit | 9400dc05357b4272425c7be47ceeced26fa3f28c (patch) | |
tree | 5fc5003b4fe930b451197b45f65e588e0065de3c /synapse/rest | |
parent | Filter out down hosts when retrying fetching device lists (#16298) (diff) | |
download | synapse-9400dc05357b4272425c7be47ceeced26fa3f28c.tar.xz |
Add the List-Unsubscribe header for notification emails. (#16274)
Adds both the List-Unsubscribe (RFC2369) and List-Unsubscribe-Post (RFC8058) headers to push notification emails, which together should: * Show an "Unsubscribe" link in the MUA UI when viewing Synapse notification emails. * Enable "one-click" unsubscribe (the user never leaves their MUA, which automatically makes a POST request to the specified endpoint).
Diffstat (limited to 'synapse/rest')
-rw-r--r-- | synapse/rest/synapse/client/unsubscribe.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/synapse/rest/synapse/client/unsubscribe.py b/synapse/rest/synapse/client/unsubscribe.py index 60321018f9..050fd7bba1 100644 --- a/synapse/rest/synapse/client/unsubscribe.py +++ b/synapse/rest/synapse/client/unsubscribe.py @@ -38,6 +38,10 @@ class UnsubscribeResource(DirectServeHtmlResource): self.macaroon_generator = hs.get_macaroon_generator() async def _async_render_GET(self, request: SynapseRequest) -> None: + """ + Handle a user opening an unsubscribe link in the browser, either via an + HTML/Text email or via the List-Unsubscribe header. + """ token = parse_string(request, "access_token", required=True) app_id = parse_string(request, "app_id", required=True) pushkey = parse_string(request, "pushkey", required=True) @@ -62,3 +66,16 @@ class UnsubscribeResource(DirectServeHtmlResource): 200, UnsubscribeResource.SUCCESS_HTML, ) + + async def _async_render_POST(self, request: SynapseRequest) -> None: + """ + Handle a mail user agent POSTing to the unsubscribe URL via the + List-Unsubscribe & List-Unsubscribe-Post headers. + """ + + # TODO Assert that the body has a single field + + # Assert the body has form encoded key/value pair of + # List-Unsubscribe=One-Click. + + await self._async_render_GET(request) |