]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/APContact.php
Standards
[friendica.git] / src / Model / APContact.php
index 0d482ced782973b5bf7f8f0aea848005f3c4f52a..bd6931c4cbe566a99bd8109bccf2fffb3a831aa0 100644 (file)
@@ -26,6 +26,7 @@ use Friendica\Core\Cache\Duration;
 use Friendica\Core\Logger;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
+use Friendica\Database\DBStructure;
 use Friendica\DI;
 use Friendica\Network\Probe;
 use Friendica\Protocol\ActivityNamespace;
@@ -192,7 +193,7 @@ class APContact
 
                $apcontact['sharedinbox'] = '';
                if (!empty($compacted['as:endpoints'])) {
-                       $apcontact['sharedinbox'] = JsonLD::fetchElement($compacted['as:endpoints'], 'as:sharedbox', '@id');
+                       $apcontact['sharedinbox'] = JsonLD::fetchElement($compacted['as:endpoints'], 'as:sharedInbox', '@id');
                        self::unarchiveInbox($apcontact['sharedinbox'], true);
                }
 
@@ -210,6 +211,11 @@ class APContact
                        $apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id');
                }
 
+               $apcontact['header'] = JsonLD::fetchElement($compacted, 'as:image', '@id');
+               if (is_array($apcontact['header']) || !empty($compacted['as:image']['as:url']['@id'])) {
+                       $apcontact['header'] = JsonLD::fetchElement($compacted['as:image'], 'as:url', '@id');
+               }
+
                if (empty($apcontact['alias'])) {
                        $apcontact['alias'] = JsonLD::fetchElement($compacted, 'as:url', '@id');
                        if (is_array($apcontact['alias'])) {
@@ -327,7 +333,7 @@ class APContact
 
                if (empty($apcontact['subscribe'])) {
                        $apcontact['subscribe'] = null;
-               }               
+               }
 
                if (!empty($apcontact['baseurl']) && empty($fetched_contact['gsid'])) {
                        $apcontact['gsid'] = GServer::getID($apcontact['baseurl']);
@@ -349,6 +355,9 @@ class APContact
                        DBA::delete('apcontact', ['url' => $url]);
                }
 
+               // Limit the length on incoming fields
+               $apcontact = DBStructure::getFieldsForTable('apcontact', $apcontact);
+
                if (DBA::exists('apcontact', ['url' => $apcontact['url']])) {
                        DBA::update('apcontact', $apcontact, ['url' => $apcontact['url']]);
                } else {
@@ -357,7 +366,7 @@ class APContact
 
                Logger::info('Updated profile', ['url' => $url]);
 
-               return $apcontact;
+               return DBA::selectFirst('apcontact', [], ['url' => $apcontact['url']]) ?: [];
        }
 
        /**