1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-23 16:24:29 +00:00
pixelfed/app/Services/StatusLabelService.php
2022-04-18 01:59:27 -06:00

33 lines
706 B
PHP

<?php
namespace App\Services;
use Illuminate\Support\Facades\Cache;
use App\Status;
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'])
];
});
}
}