forked from mirror/pixelfed
Merge pull request #877 from pixelfed/frontend-ui-refactor
Cache private profile id list
This commit is contained in:
commit
dc3e41e92b
|
@ -57,6 +57,7 @@ trait AdminReportController
|
|||
case 'unlist':
|
||||
$item->visibility = 'unlisted';
|
||||
$item->save();
|
||||
Cache::forget('profiles:private');
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
|
|
|
@ -223,11 +223,12 @@ class PublicApiController extends Controller
|
|||
// $timeline = Timeline::build()->local();
|
||||
$pid = Auth::user()->profile->id;
|
||||
|
||||
$private = Profile::whereIsPrivate(true)
|
||||
->orWhere('unlisted', true)
|
||||
->orWhere('status', '!=', null)
|
||||
->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)
|
||||
->whereFilterableType('App\Profile')
|
||||
->whereIn('filter_type', ['mute', 'block'])
|
||||
|
@ -310,7 +311,12 @@ class PublicApiController extends Controller
|
|||
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)
|
||||
->whereFilterableType('App\Profile')
|
||||
->whereIn('filter_type', ['mute', 'block'])
|
||||
|
|
|
@ -10,8 +10,7 @@ use App\Profile;
|
|||
use App\User;
|
||||
use App\UserFilter;
|
||||
use App\Util\Lexer\PrettyNumber;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Auth, Cache, DB;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
trait PrivacySettings
|
||||
|
@ -48,6 +47,7 @@ trait PrivacySettings
|
|||
$profile->{$field} = false;
|
||||
$profile->save();
|
||||
}
|
||||
Cache::forget('profiles:private');
|
||||
} elseif ($field == 'crawlable') {
|
||||
if ($form == 'on') {
|
||||
$settings->{$field} = false;
|
||||
|
|
|
@ -145,6 +145,7 @@ class SettingsController extends Controller
|
|||
$user->save();
|
||||
$profile->save();
|
||||
Auth::logout();
|
||||
Cache::forget('profiles:private');
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
|
@ -161,7 +162,6 @@ class SettingsController extends Controller
|
|||
if(config('pixelfed.account_deletion') == false) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
if($user->is_admin == true) {
|
||||
return abort(400, 'You cannot delete an admin account.');
|
||||
|
@ -174,6 +174,7 @@ class SettingsController extends Controller
|
|||
$profile->delete_after = $ts;
|
||||
$user->save();
|
||||
$profile->save();
|
||||
Cache::forget('profiles:private');
|
||||
Auth::logout();
|
||||
return redirect('/');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue