]> git.mxchange.org Git - friendica.git/commitdiff
Changed contact update rule / added logging
authorMichael <heluecht@pirati.ca>
Tue, 14 Jan 2025 06:06:28 +0000 (06:06 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 14 Jan 2025 06:06:28 +0000 (06:06 +0000)
src/Module/Photo.php
src/Worker/UpdateContact.php

index 30e6d5767251f463114ffa12a888b45ed7f0797c..87da6be55b59349070aafe597ca16a45b835d2db 100644 (file)
@@ -27,6 +27,7 @@ use Friendica\Network\HTTPException;
 use Friendica\Network\HTTPException\NotModifiedException;
 use Friendica\Object\Image;
 use Friendica\Security\OpenWebAuth;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Images;
 use Friendica\Util\ParseUrl;
 use Friendica\Util\Proxy;
@@ -297,7 +298,7 @@ class Photo extends BaseApi
 
                                return MPhoto::createPhotoForExternalResource($link['url'], (int)DI::userSession()->getLocalUserId(), $link['mimetype'] ?? '', $link['blurhash'] ?? '', $link['width'] ?? 0, $link['height'] ?? 0);
                        case 'contact':
-                               $fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'blurhash', 'xmpp', 'addr', 'network', 'failed', 'updated'];
+                               $fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'blurhash', 'xmpp', 'addr', 'network', 'failed', 'updated', 'next-update'];
                                $contact = Contact::getById($id, $fields);
                                if (empty($contact)) {
                                        return false;
@@ -355,7 +356,7 @@ class Photo extends BaseApi
                                        } else {
                                                // Only update federated accounts that hadn't failed before and hadn't been updated recently
                                                $update = in_array($contact['network'], Protocol::FEDERATED) && !$contact['failed']
-                                                       && ((time() - strtotime($contact['updated']) > 86400));
+                                                       && ($contact['next-update'] < DateTimeFormat::utcNow());
                                                if ($update) {
                                                        $curlResult = DI::httpClient()->head($url, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::IMAGE, HttpClientOptions::REQUEST => HttpClientRequest::CONTENTTYPE]);
                                                        $update = !$curlResult->isSuccess() && ($curlResult->getReturnCode() == 404);
index aad6a93db293e281b8e474ca94269eb7810f760b..ded4679fe6a8d52b48de393060d5c0b2be87ea87 100644 (file)
@@ -51,6 +51,7 @@ class UpdateContact
                        return 0;
                }
 
+               Logger::debug('Update contact', ['id' => $contact_id]);
                return Worker::add($run_parameters, 'UpdateContact', $contact_id);
        }
 }