mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
Update FollowerService, add localFollowerIds method
This commit is contained in:
parent
0fce5de6cd
commit
20a560bfd1
1 changed files with 12 additions and 0 deletions
|
@ -19,6 +19,7 @@ class FollowerService
|
|||
const FOLLOWING_SYNC_KEY = 'pf:services:followers:sync-following:';
|
||||
const FOLLOWING_KEY = 'pf:services:follow:following:id:';
|
||||
const FOLLOWERS_KEY = 'pf:services:follow:followers:id:';
|
||||
const FOLLOWERS_LOCAL_KEY = 'pf:services:follow:local-follower-ids:';
|
||||
|
||||
public static function add($actor, $target, $refresh = true)
|
||||
{
|
||||
|
@ -212,4 +213,15 @@ class FollowerService
|
|||
Cache::forget(self::FOLLOWERS_SYNC_KEY . $id);
|
||||
Cache::forget(self::FOLLOWING_SYNC_KEY . $id);
|
||||
}
|
||||
|
||||
public static function localFollowerIds($pid, $limit = 0)
|
||||
{
|
||||
$key = self::FOLLOWERS_LOCAL_KEY . $pid;
|
||||
$res = Cache::remember($key, 86400, function() use($pid) {
|
||||
return DB::table('followers')->whereFollowingId($pid)->whereLocalProfile(true)->pluck('profile_id')->sort();
|
||||
});
|
||||
return $limit ?
|
||||
$res->take($limit)->values()->toArray() :
|
||||
$res->values()->toArray();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue