]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/DFRN.php
ActivityPub: We now do support transmitting alternative image descriptions
[friendica.git] / src / Protocol / DFRN.php
index 3aa3ab957c90515d53a4d78147a8d6a0e2368676..2abdfe14869fc128a0911ecb8234f963b4f81ba4 100644 (file)
@@ -29,6 +29,7 @@ use Friendica\Model\Mail;
 use Friendica\Model\PermissionSet;
 use Friendica\Model\Profile;
 use Friendica\Model\User;
+use Friendica\Network\Probe;
 use Friendica\Object\Image;
 use Friendica\Util\BaseURL;
 use Friendica\Util\Crypto;
@@ -1455,6 +1456,11 @@ class DFRN
 
                $dest_url = ($public_batch ? $contact["batch"] : $contact["notify"]);
 
+               if (empty($dest_url)) {
+                       Logger::info('Empty destination', ['public' => $public_batch, 'contact' => $contact]);
+                       return -24;
+               }
+
                $content_type = ($public_batch ? "application/magic-envelope+xml" : "application/json");
 
                $postResult = Network::post($dest_url, $envelope, ["Content-Type: ".$content_type]);
@@ -1688,13 +1694,12 @@ class DFRN
                                'location' => $contact['location'], 'addr' => $contact['addr'], 'keywords' => $contact['keywords'],
                                'bdyear' => $contact['bdyear'], 'bd' => $contact['bd'], 'hidden' => $contact['hidden'],
                                'xmpp' => $contact['xmpp'], 'name-date' => DateTimeFormat::utc($contact['name-date']),
-                               'uri-date' => DateTimeFormat::utc($contact['uri-date'])];
+                               'unsearchable' => $contact['hidden'], 'uri-date' => DateTimeFormat::utc($contact['uri-date'])];
 
                        DBA::update('contact', $fields, ['id' => $contact['id'], 'network' => $contact['network']], $contact_old);
 
                        // Update the public contact. Don't set the "hidden" value, this is used differently for public contacts
                        unset($fields['hidden']);
-                       $fields['unsearchable'] = $hide;
                        $condition = ['uid' => 0, 'nurl' => Strings::normaliseLink($contact_old['url'])];
                        DBA::update('contact', $fields, $condition, true);
 
@@ -2172,7 +2177,7 @@ class DFRN
                if (($entrytype == DFRN::TOP_LEVEL) && !empty($importer['id'])) {
                        // The filling of the the "contact" variable is done for legcy reasons
                        // The functions below are partly used by ostatus.php as well - where we have this variable
-                       $contact = Contact::select([], ['id' => $importer['id']]);
+                       $contact = Contact::selectFirst([], ['id' => $importer['id']]);
 
                        // Big question: Do we need these functions? They were part of the "consume_feed" function.
                        // This function once was responsible for DFRN and OStatus.
@@ -3037,4 +3042,19 @@ class DFRN
 
                return (strcmp($existing_edited, $update_edited) < 0);
        }
+
+       /**
+        * Checks if the given contact url does support DFRN
+        *
+        * @param string  $url    profile url
+        * @param boolean $update Update the profile
+        * @return boolean
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        * @throws \ImagickException
+        */
+       public static function isSupportedByContactUrl($url, $update = false)
+       {
+               $probe = Probe::uri($url, Protocol::DFRN, 0, !$update);
+               return $probe['network'] == Protocol::DFRN;
+       }
 }