]> git.mxchange.org Git - friendica.git/commitdiff
Fix JsonLD parsing problems with GoToSocial
authorMichael <heluecht@pirati.ca>
Tue, 25 Jul 2023 04:33:55 +0000 (04:33 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 25 Jul 2023 04:33:55 +0000 (04:33 +0000)
src/Util/JsonLD.php
static/joinmastodon.jsonld [new file with mode: 0644]
static/schema.jsonld [new file with mode: 0644]

index 0a4d5a0b55bf40808e891f81a1d832e0377ca3c1..beb01f0cc1106f54683ed1454e15e9a8f1d8b111 100644 (file)
@@ -55,6 +55,12 @@ class JsonLD
                        case 'https://funkwhale.audio/ns':
                                $url = DI::basePath() . '/static/funkwhale.audio.jsonld';
                                break;
+                       case 'http://schema.org':
+                               $url = DI::basePath() . '/static/schema.jsonld';
+                               break;
+                       case 'http://joinmastodon.org/ns':
+                               $url = DI::basePath() . '/static/joinmastodon.jsonld';
+                               break;
                        default:
                                switch (parse_url($url, PHP_URL_PATH)) {
                                        case '/schemas/litepub-0.1.jsonld';
@@ -177,12 +183,6 @@ class JsonLD
                        if (!in_array('https://w3id.org/security/v1', $json['@context'])) {
                                $json['@context'][] = 'https://w3id.org/security/v1';
                        }
-
-                       // Issue 12419: Workaround for GoToSocial
-                       $pos = array_search('http://joinmastodon.org/ns', $json['@context']);
-                       if (is_int($pos)) {
-                               $json['@context'][$pos] = ['toot' => 'http://joinmastodon.org/ns#'];
-                       }
                }
 
                // Bookwyrm transmits "id" fields with "null", which isn't allowed.
diff --git a/static/joinmastodon.jsonld b/static/joinmastodon.jsonld
new file mode 100644 (file)
index 0000000..0edd4ab
--- /dev/null
@@ -0,0 +1,44 @@
+{
+    "@context":[
+        "https://www.w3.org/ns/activitystreams",
+        "https://w3id.org/security/v1",
+        {
+            "manuallyApprovesFollowers":"as:manuallyApprovesFollowers",
+            "toot":"http://joinmastodon.org/ns#",
+            "featured":{"@id":"toot:featured","@type":"@id"},
+            "featuredTags":{"@id":"toot:featuredTags","@type":"@id"},
+            "alsoKnownAs":{"@id":"as:alsoKnownAs","@type":"@id"},
+            "movedTo":{"@id":"as:movedTo","@type":"@id"},
+            "schema":"http://schema.org#",
+            "PropertyValue":"schema:PropertyValue",
+            "value":"schema:value",
+            "discoverable":"toot:discoverable",
+            "Device":"toot:Device",
+            "Ed25519Signature":"toot:Ed25519Signature",
+            "Ed25519Key":"toot:Ed25519Key",
+            "Curve25519Key":"toot:Curve25519Key",
+            "EncryptedMessage":"toot:EncryptedMessage",
+            "publicKeyBase64":"toot:publicKeyBase64",
+            "deviceId":"toot:deviceId",
+            "claim":{"@type":"@id","@id":"toot:claim"},
+            "fingerprintKey":{"@type":"@id","@id":"toot:fingerprintKey"},
+            "identityKey":{"@type":"@id","@id":"toot:identityKey"},
+            "devices":{"@type":"@id","@id":"toot:devices"},
+            "messageFranking":"toot:messageFranking",
+            "messageType":"toot:messageType",
+            "cipherText":"toot:cipherText",
+            "suspended":"toot:suspended",
+            "focalPoint":{"@container":"@list","@id":"toot:focalPoint"},
+            "ostatus":"http://ostatus.org#",
+            "atomUri":"ostatus:atomUri",
+            "inReplyToAtomUri":"ostatus:inReplyToAtomUri",
+            "conversation":"ostatus:conversation",
+            "sensitive":"as:sensitive",
+            "votersCount":"toot:votersCount",
+            "Hashtag":"as:Hashtag",
+            "quoteUrl":"as:quoteUrl",
+            "Emoji":"toot:Emoji",
+            "vcard":"http://www.w3.org/2006/vcard/ns#"
+        }
+    ]
+}
\ No newline at end of file
diff --git a/static/schema.jsonld b/static/schema.jsonld
new file mode 100644 (file)
index 0000000..5940137
--- /dev/null
@@ -0,0 +1,7 @@
+{
+    "@context": {
+        "schema": "http://schema.org#",
+        "value": "schema:value",
+        "PropertyValue": "schema:PropertyValue"
+    }
+}
\ No newline at end of file