From ad2db4aea7c411daed6f259653c700e2460d708b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 31 Aug 2021 00:37:02 -0600 Subject: [PATCH] Update FollowerService --- app/Services/FollowerService.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/Services/FollowerService.php b/app/Services/FollowerService.php index 931d15303..8ff951045 100644 --- a/app/Services/FollowerService.php +++ b/app/Services/FollowerService.php @@ -49,14 +49,28 @@ class FollowerService return (new self)->getAudienceInboxes($profile); } - protected function getAudienceInboxes($profile, $scope = null) + public static function softwareAudience($profile, $software = 'pixelfed') { - if(!$profile instanceOf Profile) { - return []; - } + return collect(self::audience($profile)) + ->filter(function($inbox) use($software) { + $domain = parse_url($inbox, PHP_URL_HOST); + if(!$domain) { + return false; + } + return InstanceService::software($domain) === strtolower($software); + }) + ->unique() + ->values(); + } - $key = 'pf:services:follow:audience:' . $profile->id; - return Cache::remember($key, 86400, function() use($profile) { + protected function getAudienceInboxes($pid, $scope = null) + { + $key = 'pf:services:follow:audience:' . $pid; + return Cache::remember($key, 86400, function() use($pid) { + $profile = Profile::find($pid); + if(!$profile) { + return []; + } return $profile ->followers() ->whereLocalProfile(false)