mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 08:44:49 +00:00
Update InternalApiController
This commit is contained in:
parent
e7c4f084bc
commit
f153a66701
1 changed files with 12 additions and 3 deletions
|
@ -6,12 +6,14 @@ use Illuminate\Http\Request;
|
||||||
use App\{
|
use App\{
|
||||||
DirectMessage,
|
DirectMessage,
|
||||||
Hashtag,
|
Hashtag,
|
||||||
|
Follower,
|
||||||
Like,
|
Like,
|
||||||
Media,
|
Media,
|
||||||
Notification,
|
Notification,
|
||||||
Profile,
|
Profile,
|
||||||
StatusHashtag,
|
StatusHashtag,
|
||||||
Status,
|
Status,
|
||||||
|
UserFilter,
|
||||||
};
|
};
|
||||||
use Auth,Cache;
|
use Auth,Cache;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
@ -122,8 +124,16 @@ class InternalApiController extends Controller
|
||||||
public function discover(Request $request)
|
public function discover(Request $request)
|
||||||
{
|
{
|
||||||
$profile = Auth::user()->profile;
|
$profile = Auth::user()->profile;
|
||||||
|
$pid = $profile->id;
|
||||||
|
//$following = Cache::get('feature:discover:following:'.$profile->id, []);
|
||||||
|
$following = Follower::whereProfileId($pid)->pluck('following_id');
|
||||||
|
|
||||||
|
$filtered = UserFilter::whereUserId($pid)
|
||||||
|
->whereFilterableType('App\Profile')
|
||||||
|
->whereIn('filter_type', ['mute', 'block'])
|
||||||
|
->pluck('filterable_id')->toArray();
|
||||||
|
$following = array_merge($following->push($pid)->toArray(), $filtered);
|
||||||
|
|
||||||
$following = Cache::get('feature:discover:following:'.$profile->id, []);
|
|
||||||
$people = Profile::select('id', 'name', 'username')
|
$people = Profile::select('id', 'name', 'username')
|
||||||
->with('avatar')
|
->with('avatar')
|
||||||
->inRandomOrder()
|
->inRandomOrder()
|
||||||
|
@ -141,7 +151,6 @@ class InternalApiController extends Controller
|
||||||
})
|
})
|
||||||
->whereIsNsfw(false)
|
->whereIsNsfw(false)
|
||||||
->whereVisibility('public')
|
->whereVisibility('public')
|
||||||
->where('profile_id', '<>', $profile->id)
|
|
||||||
->whereNotIn('profile_id', $following)
|
->whereNotIn('profile_id', $following)
|
||||||
->withCount(['comments', 'likes'])
|
->withCount(['comments', 'likes'])
|
||||||
->orderBy('created_at', 'desc')
|
->orderBy('created_at', 'desc')
|
||||||
|
|
Loading…
Reference in a new issue