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

Commit ef8e11b

Browse files
committed
Add code to rewrite Tchap Sygnal URL
1 parent 0ebdde8 commit ef8e11b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

synapse/rest/client/v1/pusher.py

Lines changed: 13 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

@@ -107,6 +108,18 @@ async def on_POST(self, request):
107108
logger.debug("set pushkey %s to kind %s", content["pushkey"], content["kind"])
108109
logger.debug("Got pushers request with body: %r", content)
109110

111+
# rewrite push url from m.org sygnal to Tchap sygnal
112+
good_sygnal_url = None
113+
if content["app_id"].start_with("fr.gouv.btchap"):
114+
good_sygnal_url = "https://sygnal.preprod.tchap.gouv.fr"
115+
if content["app_id"].start_with("fr.gouv.tchap"):
116+
good_sygnal_url = "https://sygnal.tchap.gouv.fr"
117+
118+
if good_sygnal_url:
119+
parsed_data = json_decoder.decode(content["data"])
120+
parsed_data["url"] = parsed_data["url"].replace("https://matrix.org", good_sygnal_url)
121+
content["data"] = json_encoder.encode(parsed_data)
122+
110123
append = False
111124
if "append" in content:
112125
append = content["append"]

0 commit comments

Comments
 (0)