]> git.mxchange.org Git - friendica.git/commitdiff
Update the contact in the background
authorMichael <heluecht@pirati.ca>
Mon, 8 Apr 2019 21:05:33 +0000 (21:05 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 8 Apr 2019 21:05:33 +0000 (21:05 +0000)
src/Model/Contact.php

index 2072044b30aa70d992d4d79bef4a2b38c65e72eb..2916cf1bb23288c107594fcbc2193a66cebc52ed 100644 (file)
@@ -1254,6 +1254,12 @@ class Contact extends BaseObject
                        if (empty($contact['avatar'])) {
                                $update_contact = true;
                        }
+
+                       // Update the contact in the background if needed
+                       if ($update_contact && $no_update) {
+                               Worker::add(PRIORITY_LOW, "UpdateContact", $contact_id);
+                       }
+
                        if (!$update_contact || $no_update) {
                                return $contact_id;
                        }
@@ -1265,8 +1271,10 @@ class Contact extends BaseObject
                // When we don't want to update, we look if we know this contact in any way
                if ($no_update && empty($default)) {
                        $data = self::getProbeDataFromDatabase($url);
+                       $background_update = true;
                } else {
                        $data = [];
+                       $background_update = false;
                }
 
                if (empty($data)) {
@@ -1345,6 +1353,11 @@ class Contact extends BaseObject
 
                        $contact_id = $contacts[0]["id"];
 
+                       // Update in the background when we fetched the data solely from the database
+                       if ($background_update) {
+                               Worker::add(PRIORITY_LOW, "UpdateContact", $contact_id);
+                       }
+
                        // Update the newly created contact from data in the gcontact table
                        $gcontact = DBA::selectFirst('gcontact', ['location', 'about', 'keywords', 'gender'], ['nurl' => Strings::normaliseLink($data["url"])]);
                        if (DBA::isResult($gcontact)) {