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

Commit

Permalink
Add a servlet to handle legacy "delete pusher" route
Browse files Browse the repository at this point in the history
Signed-off-by: Quentin Gliech <quenting@element.io>
  • Loading branch information
sandhose committed Jun 13, 2022
1 parent deae645 commit ea10b3f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ def _configure_named_resource(

resources.update(
{
**build_synapse_client_resource_tree(self),
CLIENT_API_PREFIX: client_resource,
"/.well-known": well_known_resource(self),
"/_synapse/admin": AdminRestResource(self),
**build_synapse_client_resource_tree(self),
}
)

Expand Down
18 changes: 18 additions & 0 deletions synapse/rest/client/pusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from synapse.http.site import SynapseRequest
from synapse.push import PusherConfigException
from synapse.rest.client._base import client_patterns
from synapse.rest.synapse.client.unsubscribe import UnsubscribeResource
from synapse.types import JsonDict

if TYPE_CHECKING:
Expand Down Expand Up @@ -132,6 +133,23 @@ async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]:
return 200, {}


class LegacyPushersRemoveRestServlet(RestServlet):
"""
A servlet to handle legacy "email unsubscribe" links, forwarding requests to the ``UnsubscribeResource``
"""

PATTERNS = client_patterns("/pushers/remove$", releases=[], v1=False, unstable=True)

def __init__(self, hs: "HomeServer"):
super().__init__()
self._resource = UnsubscribeResource(hs)

async def on_GET(self, request: SynapseRequest) -> None:
# Forward the request to the UnsubscribeResource
await self._resource._async_render(request)


def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None:
PushersRestServlet(hs).register(http_server)
PushersSetRestServlet(hs).register(http_server)
LegacyPushersRemoveRestServlet(hs).register(http_server)
2 changes: 0 additions & 2 deletions synapse/rest/synapse/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ def build_synapse_client_resource_tree(hs: "HomeServer") -> Mapping[str, Resourc
"/_synapse/client/sso_register": SsoRegisterResource(hs),
# Unsubscribe to notification emails link
"/_synapse/client/unsubscribe": UnsubscribeResource(hs),
# Legacy endpoint
"/_matrix/client/unstable/pushers/remove": UnsubscribeResource(hs),
}

# provider-specific SSO bits. Only load these if they are enabled, since they
Expand Down

0 comments on commit ea10b3f

Please sign in to comment.