diff sat/plugins/plugin_comp_ap_gateway/http_server.py @ 3994:69d970f974ff

component AP gateway: don't percent-encode `@`: Mastodon doesn't like when "@" is percent-encoded (because it doesn't do it, and it checks that the URL matches the ID without taking care of percent-encoding).
author Goffi <goffi@goffi.org>
date Fri, 10 Feb 2023 17:20:02 +0100
parents 1c84268752a1
children 27e5294649c2
line wrap: on
line diff
--- a/sat/plugins/plugin_comp_ap_gateway/http_server.py	Mon Dec 05 11:54:47 2022 +0100
+++ b/sat/plugins/plugin_comp_ap_gateway/http_server.py	Fri Feb 10 17:20:02 2023 +0100
@@ -592,7 +592,9 @@
                 "https://w3id.org/security/v1"
             ],
 
-            "id": ap_url,
+            # XXX: Mastodon doesn't like percent-encode arobas, so we have to unescape it
+            #   if it is escaped
+            "id": ap_url.replace("%40", "@"),
             "type": "Person",
             "preferredUsername": preferred_username,
             "inbox": inbox,
@@ -637,7 +639,8 @@
         return parse.urljoin(
             f"https://{self.apg.public_url}",
             request.path.decode().rstrip("/")
-        )
+        # we unescape "@" for the same reason as in [APActorRequest]
+        ).replace("%40", "@")
 
     def queryData2RSMRequest(
         self,