whereFollowingId($target)->exists(); } public static function audience($profile, $scope = null) { return (new self)->getAudienceInboxes($profile, $scope); } public static function softwareAudience($profile, $software = 'pixelfed') { 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() ->toArray(); } 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) ->get() ->map(function($follow) { return $follow->sharedInbox ?? $follow->inbox_url; }) ->unique() ->values() ->toArray(); }); } }