mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 08:13:16 +00:00
Update AdminApiController, include more data for getUser method
This commit is contained in:
parent
52f9999fcc
commit
4f850e54ad
1 changed files with 28 additions and 11 deletions
|
@ -18,6 +18,8 @@ use App\{
|
||||||
Status,
|
Status,
|
||||||
User
|
User
|
||||||
};
|
};
|
||||||
|
use App\Models\Conversation;
|
||||||
|
use App\Models\RemoteReport;
|
||||||
use App\Services\AccountService;
|
use App\Services\AccountService;
|
||||||
use App\Services\AdminStatsService;
|
use App\Services\AdminStatsService;
|
||||||
use App\Services\ConfigCacheService;
|
use App\Services\ConfigCacheService;
|
||||||
|
@ -405,6 +407,9 @@ class AdminApiController extends Controller
|
||||||
{
|
{
|
||||||
abort_if(!$request->user(), 404);
|
abort_if(!$request->user(), 404);
|
||||||
abort_unless($request->user()->is_admin == 1, 404);
|
abort_unless($request->user()->is_admin == 1, 404);
|
||||||
|
$this->validate($request, [
|
||||||
|
'sort' => 'sometimes|in:asc,desc',
|
||||||
|
]);
|
||||||
$q = $request->input('q');
|
$q = $request->input('q');
|
||||||
$sort = $request->input('sort', 'desc') === 'asc' ? 'asc' : 'desc';
|
$sort = $request->input('sort', 'desc') === 'asc' ? 'asc' : 'desc';
|
||||||
$res = User::whereNull('status')
|
$res = User::whereNull('status')
|
||||||
|
@ -422,17 +427,29 @@ class AdminApiController extends Controller
|
||||||
abort_unless($request->user()->is_admin == 1, 404);
|
abort_unless($request->user()->is_admin == 1, 404);
|
||||||
|
|
||||||
$id = $request->input('user_id');
|
$id = $request->input('user_id');
|
||||||
$user = User::findOrFail($id);
|
$key = 'pf-admin-api:getUser:byId:' . $id;
|
||||||
$profile = $user->profile;
|
if($request->has('refresh')) {
|
||||||
$account = AccountService::get($user->profile_id, true);
|
Cache::forget($key);
|
||||||
return (new AdminUser($user))->additional(['meta' => [
|
}
|
||||||
'account' => $account,
|
return Cache::remember($key, 86400, function() use($id) {
|
||||||
'moderation' => [
|
$user = User::findOrFail($id);
|
||||||
'unlisted' => (bool) $profile->unlisted,
|
$profile = $user->profile;
|
||||||
'cw' => (bool) $profile->cw,
|
$account = AccountService::get($user->profile_id, true);
|
||||||
'no_autolink' => (bool) $profile->no_autolink
|
$res = (new AdminUser($user))->additional(['meta' => [
|
||||||
]
|
'cached_at' => str_replace('+00:00', 'Z', now()->format(DATE_RFC3339_EXTENDED)),
|
||||||
]]);
|
'account' => $account,
|
||||||
|
'dms_sent' => Conversation::whereFromId($profile->id)->count(),
|
||||||
|
'report_count' => Report::where('object_id', $profile->id)->orWhere('reported_profile_id', $profile->id)->count(),
|
||||||
|
'remote_report_count' => RemoteReport::whereAccountId($profile->id)->count(),
|
||||||
|
'moderation' => [
|
||||||
|
'unlisted' => (bool) $profile->unlisted,
|
||||||
|
'cw' => (bool) $profile->cw,
|
||||||
|
'no_autolink' => (bool) $profile->no_autolink
|
||||||
|
]
|
||||||
|
]]);
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function userAdminAction(Request $request)
|
public function userAdminAction(Request $request)
|
||||||
|
|
Loading…
Reference in a new issue