forked from mirror/pixelfed
Update SiteController
This commit is contained in:
parent
53e8da4837
commit
226d810159
1 changed files with 22 additions and 22 deletions
|
@ -33,12 +33,19 @@ class SiteController extends Controller
|
||||||
{
|
{
|
||||||
$pid = Auth::user()->profile->id;
|
$pid = Auth::user()->profile->id;
|
||||||
// TODO: Use redis for timelines
|
// TODO: Use redis for timelines
|
||||||
$following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id');
|
$following = Cache::rememberForever("user:following:list:$pid", function() use($pid) {
|
||||||
$following->push(Auth::user()->profile->id);
|
$following = Follower::whereProfileId($pid)->pluck('following_id');
|
||||||
$filtered = UserFilter::whereUserId($pid)
|
$following->push($pid);
|
||||||
->whereFilterableType('App\Profile')
|
return $following->toArray();
|
||||||
->whereIn('filter_type', ['mute', 'block'])
|
});
|
||||||
->pluck('filterable_id');
|
|
||||||
|
$filtered = Cache::rememberForever("user:filter:list:$pid", function() use($pid) {
|
||||||
|
return UserFilter::whereUserId($pid)
|
||||||
|
->whereFilterableType('App\Profile')
|
||||||
|
->whereIn('filter_type', ['mute', 'block'])
|
||||||
|
->pluck('filterable_id')->toArray();
|
||||||
|
});
|
||||||
|
|
||||||
$timeline = Status::whereIn('profile_id', $following)
|
$timeline = Status::whereIn('profile_id', $following)
|
||||||
->whereNotIn('profile_id', $filtered)
|
->whereNotIn('profile_id', $filtered)
|
||||||
->whereHas('media')
|
->whereHas('media')
|
||||||
|
@ -53,29 +60,22 @@ class SiteController extends Controller
|
||||||
|
|
||||||
public function changeLocale(Request $request, $locale)
|
public function changeLocale(Request $request, $locale)
|
||||||
{
|
{
|
||||||
if (!App::isLocale($locale)) {
|
// todo: add other locales after pushing new l10n strings
|
||||||
return redirect()->back();
|
$locales = ['en'];
|
||||||
|
if(in_array($locale, $locales)) {
|
||||||
|
session()->put('locale', $locale);
|
||||||
}
|
}
|
||||||
App::setLocale($locale);
|
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function about()
|
public function about()
|
||||||
{
|
{
|
||||||
$res = Cache::remember('site:page:about', 15, function () {
|
return view('site.about');
|
||||||
$statuses = Status::whereHas('media')
|
}
|
||||||
->whereNull('in_reply_to_id')
|
|
||||||
->whereNull('reblog_of_id')
|
|
||||||
->count();
|
|
||||||
$statusCount = PrettyNumber::convert($statuses);
|
|
||||||
$userCount = PrettyNumber::convert(User::count());
|
|
||||||
$remoteCount = PrettyNumber::convert(Profile::whereNotNull('remote_url')->count());
|
|
||||||
$adminContact = User::whereIsAdmin(true)->first();
|
|
||||||
|
|
||||||
return view('site.about')->with(compact('statusCount', 'userCount', 'remoteCount', 'adminContact'))->render();
|
public function language()
|
||||||
});
|
{
|
||||||
|
return view('site.language');
|
||||||
return $res;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue