From c088249e1bb85323fccafe314a433fe2a422f43e Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 8 Apr 2019 21:05:33 +0000 Subject: [PATCH] Update the contact in the background --- src/Model/Contact.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 2072044b3..2916cf1bb 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -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)) {