Update UserFilterService, add domainBlocks method

This commit is contained in:
Daniel Supernault 2023-12-21 00:42:26 -07:00
parent b3148b788e
commit 6d55cb27ee
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

@ -4,12 +4,14 @@ namespace App\Services;
use Cache;
use App\UserFilter;
use App\Models\UserDomainBlock;
use Illuminate\Support\Facades\Redis;
class UserFilterService
{
const USER_MUTES_KEY = 'pf:services:mutes:ids:';
const USER_BLOCKS_KEY = 'pf:services:blocks:ids:';
const USER_DOMAIN_KEY = 'pf:services:domain-blocks:ids:';
public static function mutes(int $profile_id)
{
@ -145,4 +147,17 @@ class UserFilterService
{
return Redis::zcard(self::USER_MUTES_KEY . $profile_id);
}
public static function domainBlocks($pid, $purge = false)
{
if($purge) {
Cache::forget(self::USER_DOMAIN_KEY . $pid);
}
return Cache::remember(
self::USER_DOMAIN_KEY . $pid,
21600,
function() use($pid) {
return UserDomainBlock::whereProfileId($pid)->pluck('domain')->toArray();
});
}
}