]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/APContact.php
Improved definition style
[friendica.git] / src / Model / APContact.php
index 7ce47bb227ec04e39804680947228533ac696328..ec33864f4dc78f9be9cd70e946b406b1d36879a6 100644 (file)
@@ -26,6 +26,7 @@ use Friendica\Core\Logger;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Protocol\ActivityPub;
+use Friendica\Util\Crypto;
 use Friendica\Util\Network;
 use Friendica\Util\JsonLD;
 use Friendica\Util\DateTimeFormat;
@@ -209,6 +210,9 @@ class APContact
                $apcontact['pubkey'] = null;
                if (!empty($compacted['w3id:publicKey'])) {
                        $apcontact['pubkey'] = trim(JsonLD::fetchElement($compacted['w3id:publicKey'], 'w3id:publicKeyPem', '@value'));
+                       if (strstr($apcontact['pubkey'], 'RSA ')) {
+                               $apcontact['pubkey'] = Crypto::rsaToPem($apcontact['pubkey']);
+                       }
                }
 
                $apcontact['manually-approve'] = (int)JsonLD::fetchElement($compacted, 'as:manuallyApprovesFollowers');
@@ -256,6 +260,22 @@ class APContact
                // Unhandled from Kroeg
                // kroeg:blocks, updated
 
+               // When the photo is too large, try to shorten it by removing parts
+               if (strlen($apcontact['photo']) > 255) {
+                       $parts = parse_url($apcontact['photo']);
+                       unset($parts['fragment']);
+                       $apcontact['photo'] = Network::unparseURL($parts);
+
+                       if (strlen($apcontact['photo']) > 255) {
+                               unset($parts['query']);
+                               $apcontact['photo'] = Network::unparseURL($parts);
+                       }
+
+                       if (strlen($apcontact['photo']) > 255) {
+                               $apcontact['photo'] = substr($apcontact['photo'], 0, 255);
+                       }
+               }
+
                $parts = parse_url($apcontact['url']);
                unset($parts['path']);
                $baseurl = Network::unparseURL($parts);