From 3d1829ede577de8ca37bf29128f666827ffdf0f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 19 Aug 2020 05:18:19 +0000 Subject: [PATCH] Don't poll locally / user self data --- src/Model/Contact.php | 8 ++++++++ src/Worker/OnePoll.php | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 7772bad87..ed8bc7d55 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1576,12 +1576,20 @@ class Contact return; } + $local_uid = User::getIdForURL($contact['url']); + if (!empty($local_uid)) { + $fields = self::selectFirst(['avatar', 'avatar-date', 'photo', 'thumb', 'micro'], ['self' => true, 'uid' => $local_uid]); + } + // Replace cached avatar pictures from the default avatar with the default avatars in different sizes if (strpos($avatar, self::DEFAULT_AVATAR_PHOTO)) { $fields = ['avatar' => $avatar, 'avatar-date' => DateTimeFormat::utcNow(), 'photo' => DI::baseUrl() . self::DEFAULT_AVATAR_PHOTO, 'thumb' => DI::baseUrl() . self::DEFAULT_AVATAR_THUMB, 'micro' => DI::baseUrl() . self::DEFAULT_AVATAR_MICRO]; + } + + if (!empty($fields)) { if ($fields['photo'] . $fields['thumb'] . $fields['micro'] != $contact['photo'] . $contact['thumb'] . $contact['micro']) { DBA::update('contact', $fields, ['id' => $cid]); Photo::delete(['uid' => $uid, 'contact-id' => $cid, 'album' => Photo::CONTACT_PHOTOS]); diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 4dfbf7cad..867b11fd3 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -103,6 +103,15 @@ class OnePoll return; } + // Don't poll local contacts + if (Contact::isLocalById($contact['id'])) { + Logger::info('Local contacts are not polled', ['id' => $contact['id']]); + + // set the last-update so we don't keep polling + DBA::update('contact', ['last-update' => $updated], ['id' => $contact['id']]); + return; + } + // We don't poll AP contacts by now if ($protocol === Protocol::ACTIVITYPUB) { Logger::log("Don't poll AP contact");