mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
865 B
PHP
34 lines
865 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Status;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Str;
|
|
|
|
class StatusLabelService
|
|
{
|
|
const CACHE_KEY = 'pf:services:status_label:_v0:';
|
|
|
|
public static function get(Status $status)
|
|
{
|
|
if (config('instance.label.covid.enabled') == false || ! $status) {
|
|
return [
|
|
'covid' => false,
|
|
];
|
|
}
|
|
|
|
return Cache::remember(self::CACHE_KEY.$status->id, now()->addDays(7), function () use ($status) {
|
|
if (! $status->caption) {
|
|
return [
|
|
'covid' => false,
|
|
];
|
|
}
|
|
|
|
return [
|
|
'covid' => Str::of(strtolower($status->caption))->contains(['covid', 'corona', 'coronavirus', 'vaccine', 'vaxx', 'vaccination', 'plandemic']),
|
|
];
|
|
});
|
|
}
|
|
}
|