From 30b9af10aceb117bf3ea6ba7b049412e71094906 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 15 May 2022 09:08:35 +0000 Subject: [PATCH] Fetch featured posts through a worker --- src/Model/Contact.php | 5 +++- src/Worker/FetchFeaturedPosts.php | 39 +++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/Worker/FetchFeaturedPosts.php diff --git a/src/Model/Contact.php b/src/Model/Contact.php index c666fed7bf..d0febc8bba 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -2316,7 +2316,10 @@ class Contact if ($uid == 0) { if ($ret['network'] == Protocol::ACTIVITYPUB) { - ActivityPub\Processor::fetchFeaturedPosts($ret['url']); + $apcontact = APContact::getByURL($ret['url'], false); + if (!empty($apcontact['featured'])) { + Worker::add(PRIORITY_LOW, 'FetchFeaturedPosts', $ret['url']); + } } $ret['last-item'] = Probe::getLastUpdate($ret); diff --git a/src/Worker/FetchFeaturedPosts.php b/src/Worker/FetchFeaturedPosts.php new file mode 100644 index 0000000000..757cc9c460 --- /dev/null +++ b/src/Worker/FetchFeaturedPosts.php @@ -0,0 +1,39 @@ +. + * + */ + +namespace Friendica\Worker; + +use Friendica\Core\Logger; +use Friendica\Protocol\ActivityPub; + +class FetchFeaturedPosts +{ + /** + * Fetch featured posts from a contact with the given URL + * @param string $url Contact URL + */ + public static function execute(string $url) + { + Logger::info('Start fetching featured posts', ['url' => $url]); + ActivityPub\Processor::fetchFeaturedPosts($url); + Logger::info('Finished fetching featured posts', ['url' => $url]); + } +}