mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-18 11:03:17 +00:00
Fix BeagleService
This commit is contained in:
parent
18837dc15b
commit
81018265db
1 changed files with 29 additions and 18 deletions
|
@ -16,6 +16,8 @@ class BeagleService
|
||||||
|
|
||||||
const DISCOVER_CACHE_KEY = 'pf:services:beagle:discover:v1';
|
const DISCOVER_CACHE_KEY = 'pf:services:beagle:discover:v1';
|
||||||
|
|
||||||
|
const DISCOVER_POSTS_CACHE_KEY = 'pf:services:beagle:discover-posts:v1';
|
||||||
|
|
||||||
public static function getDefaultRules()
|
public static function getDefaultRules()
|
||||||
{
|
{
|
||||||
return Cache::remember(self::DEFAULT_RULES_CACHE_KEY, now()->addDays(7), function () {
|
return Cache::remember(self::DEFAULT_RULES_CACHE_KEY, now()->addDays(7), function () {
|
||||||
|
@ -82,27 +84,36 @@ class BeagleService
|
||||||
|
|
||||||
public static function getDiscoverPosts()
|
public static function getDiscoverPosts()
|
||||||
{
|
{
|
||||||
$posts = collect(self::getDiscover())
|
return Cache::remember(self::DISCOVER_POSTS_CACHE_KEY, now()->addHours(1), function () {
|
||||||
->filter(function ($post) {
|
$posts = collect(self::getDiscover())
|
||||||
$bannedInstances = InstanceService::getBannedDomains();
|
->filter(function ($post) {
|
||||||
$domain = parse_url($post['id'], PHP_URL_HOST);
|
$bannedInstances = InstanceService::getBannedDomains();
|
||||||
|
$domain = parse_url($post['id'], PHP_URL_HOST);
|
||||||
|
|
||||||
return ! in_array($domain, $bannedInstances);
|
return ! in_array($domain, $bannedInstances);
|
||||||
})
|
})
|
||||||
->map(function ($post) {
|
->map(function ($post) {
|
||||||
$domain = parse_url($post['id'], PHP_URL_HOST);
|
$domain = parse_url($post['id'], PHP_URL_HOST);
|
||||||
if ($domain === config_cache('pixelfed.domain.app')) {
|
if ($domain === config_cache('pixelfed.domain.app')) {
|
||||||
$parts = explode('/', $post['id']);
|
$parts = explode('/', $post['id']);
|
||||||
$id = array_last($parts);
|
$id = array_last($parts);
|
||||||
|
|
||||||
|
return StatusService::get($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$post = Helpers::statusFetch($post['id']);
|
||||||
|
if (! $post) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$id = $post->id;
|
||||||
|
|
||||||
return StatusService::get($id);
|
return StatusService::get($id);
|
||||||
}
|
})
|
||||||
|
->filter()
|
||||||
|
->values()
|
||||||
|
->toArray();
|
||||||
|
|
||||||
return Helpers::statusFetch($post['id']);
|
return $posts;
|
||||||
})
|
});
|
||||||
->values()
|
|
||||||
->toArray();
|
|
||||||
|
|
||||||
return $posts;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue