mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-14 02:24:31 +00:00
Merge pull request #877 from pixelfed/frontend-ui-refactor
Cache private profile id list
This commit is contained in:
commit
dc3e41e92b
4 changed files with 17 additions and 9 deletions
|
@ -57,6 +57,7 @@ trait AdminReportController
|
||||||
case 'unlist':
|
case 'unlist':
|
||||||
$item->visibility = 'unlisted';
|
$item->visibility = 'unlisted';
|
||||||
$item->save();
|
$item->save();
|
||||||
|
Cache::forget('profiles:private');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
|
|
|
@ -223,11 +223,12 @@ class PublicApiController extends Controller
|
||||||
// $timeline = Timeline::build()->local();
|
// $timeline = Timeline::build()->local();
|
||||||
$pid = Auth::user()->profile->id;
|
$pid = Auth::user()->profile->id;
|
||||||
|
|
||||||
$private = Profile::whereIsPrivate(true)
|
$private = Cache::remember('profiles:private', 1440, function() {
|
||||||
|
return Profile::whereIsPrivate(true)
|
||||||
->orWhere('unlisted', true)
|
->orWhere('unlisted', true)
|
||||||
->orWhere('status', '!=', null)
|
->orWhere('status', '!=', null)
|
||||||
->where('id', '!=', $pid)
|
|
||||||
->pluck('id');
|
->pluck('id');
|
||||||
|
});
|
||||||
$filters = UserFilter::whereUserId($pid)
|
$filters = UserFilter::whereUserId($pid)
|
||||||
->whereFilterableType('App\Profile')
|
->whereFilterableType('App\Profile')
|
||||||
->whereIn('filter_type', ['mute', 'block'])
|
->whereIn('filter_type', ['mute', 'block'])
|
||||||
|
@ -310,7 +311,12 @@ class PublicApiController extends Controller
|
||||||
return $following->push($pid)->toArray();
|
return $following->push($pid)->toArray();
|
||||||
});
|
});
|
||||||
|
|
||||||
$private = Profile::whereIsPrivate(true)->orWhereNotNull('status')->where('id', '!=', $pid)->pluck('id');
|
$private = Cache::remember('profiles:private', 1440, function() {
|
||||||
|
return Profile::whereIsPrivate(true)
|
||||||
|
->orWhere('unlisted', true)
|
||||||
|
->orWhere('status', '!=', null)
|
||||||
|
->pluck('id');
|
||||||
|
});
|
||||||
$filters = UserFilter::whereUserId($pid)
|
$filters = UserFilter::whereUserId($pid)
|
||||||
->whereFilterableType('App\Profile')
|
->whereFilterableType('App\Profile')
|
||||||
->whereIn('filter_type', ['mute', 'block'])
|
->whereIn('filter_type', ['mute', 'block'])
|
||||||
|
|
|
@ -10,8 +10,7 @@ use App\Profile;
|
||||||
use App\User;
|
use App\User;
|
||||||
use App\UserFilter;
|
use App\UserFilter;
|
||||||
use App\Util\Lexer\PrettyNumber;
|
use App\Util\Lexer\PrettyNumber;
|
||||||
use Auth;
|
use Auth, Cache, DB;
|
||||||
use DB;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
trait PrivacySettings
|
trait PrivacySettings
|
||||||
|
@ -48,6 +47,7 @@ trait PrivacySettings
|
||||||
$profile->{$field} = false;
|
$profile->{$field} = false;
|
||||||
$profile->save();
|
$profile->save();
|
||||||
}
|
}
|
||||||
|
Cache::forget('profiles:private');
|
||||||
} elseif ($field == 'crawlable') {
|
} elseif ($field == 'crawlable') {
|
||||||
if ($form == 'on') {
|
if ($form == 'on') {
|
||||||
$settings->{$field} = false;
|
$settings->{$field} = false;
|
||||||
|
|
|
@ -145,6 +145,7 @@ class SettingsController extends Controller
|
||||||
$user->save();
|
$user->save();
|
||||||
$profile->save();
|
$profile->save();
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
|
Cache::forget('profiles:private');
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +162,6 @@ class SettingsController extends Controller
|
||||||
if(config('pixelfed.account_deletion') == false) {
|
if(config('pixelfed.account_deletion') == false) {
|
||||||
abort(404);
|
abort(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
if($user->is_admin == true) {
|
if($user->is_admin == true) {
|
||||||
return abort(400, 'You cannot delete an admin account.');
|
return abort(400, 'You cannot delete an admin account.');
|
||||||
|
@ -174,6 +174,7 @@ class SettingsController extends Controller
|
||||||
$profile->delete_after = $ts;
|
$profile->delete_after = $ts;
|
||||||
$user->save();
|
$user->save();
|
||||||
$profile->save();
|
$profile->save();
|
||||||
|
Cache::forget('profiles:private');
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue