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

Commit b906522

Browse files
committed
Add code to rewrite Tchap Sygnal URL
1 parent 435431a commit b906522

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

changelog.d/69.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add code to rewrite Tchap Sygnal URL.

synapse/rest/client/v1/pusher.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
)
2626
from synapse.push import PusherConfigException
2727
from synapse.rest.client.v2_alpha._base import client_patterns
28+
from synapse.util import json_decoder, json_encoder
2829

2930
logger = logging.getLogger(__name__)
3031

@@ -91,6 +92,16 @@ async def on_POST(self, request):
9192
logger.debug("set pushkey %s to kind %s", content["pushkey"], content["kind"])
9293
logger.debug("Got pushers request with body: %r", content)
9394

95+
# rewrite push url from m.org sygnal to Tchap sygnal
96+
if content["app_id"].startswith("fr.gouv."):
97+
good_sygnal_url = "http://sygnal.tchap.gouv.fr"
98+
99+
parsed_data = json_decoder.decode(content["data"])
100+
parsed_data["url"] = parsed_data["url"].replace(
101+
"https://matrix.org", good_sygnal_url
102+
)
103+
content["data"] = json_encoder.encode(parsed_data)
104+
94105
append = False
95106
if "append" in content:
96107
append = content["append"]

0 commit comments

Comments
 (0)