mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
commit
6dc2c5fd8f
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,6 +84,7 @@ class BeagleService
|
||||||
|
|
||||||
public static function getDiscoverPosts()
|
public static function getDiscoverPosts()
|
||||||
{
|
{
|
||||||
|
return Cache::remember(self::DISCOVER_POSTS_CACHE_KEY, now()->addHours(1), function () {
|
||||||
$posts = collect(self::getDiscover())
|
$posts = collect(self::getDiscover())
|
||||||
->filter(function ($post) {
|
->filter(function ($post) {
|
||||||
$bannedInstances = InstanceService::getBannedDomains();
|
$bannedInstances = InstanceService::getBannedDomains();
|
||||||
|
@ -98,11 +101,19 @@ class BeagleService
|
||||||
return StatusService::get($id);
|
return StatusService::get($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Helpers::statusFetch($post['id']);
|
$post = Helpers::statusFetch($post['id']);
|
||||||
|
if (! $post) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$id = $post->id;
|
||||||
|
|
||||||
|
return StatusService::get($id);
|
||||||
})
|
})
|
||||||
|
->filter()
|
||||||
->values()
|
->values()
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
return $posts;
|
return $posts;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue