mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update UserFilterService, add domainBlocks method
This commit is contained in:
parent
b3148b788e
commit
6d55cb27ee
1 changed files with 143 additions and 128 deletions
|
@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue