1
0
Fork 0
forked from mirror/pixelfed

Update v1.1 api

This commit is contained in:
Daniel Supernault 2022-09-24 23:20:45 -06:00
parent 78d82c7c2c
commit 613e98ce09
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -260,18 +260,20 @@ class ApiV1Dot1Controller extends Controller
abort_if(!$user, 403); abort_if(!$user, 403);
abort_if($user->status != null, 403); abort_if($user->status != null, 403);
$agent = new Agent(); $agent = new Agent();
$currentIp = $request->ip();
$activity = AccountLog::whereUserId($user->id) $activity = AccountLog::whereUserId($user->id)
->whereAction('auth.login') ->whereAction('auth.login')
->orderBy('created_at', 'desc') ->orderBy('created_at', 'desc')
->limit(10) ->limit(10)
->get() ->get()
->map(function($item) use($agent) { ->map(function($item) use($agent, $currentIp) {
$agent->setUserAgent($item->user_agent); $agent->setUserAgent($item->user_agent);
return [ return [
'id' => $item->id, 'id' => $item->id,
'action' => $item->action, 'action' => $item->action,
'ip' => $item->ip_address, 'ip' => $item->ip_address,
'ip_current' => $item->ip_address === $currentIp,
'is_mobile' => $agent->isMobile(), 'is_mobile' => $agent->isMobile(),
'device' => $agent->device(), 'device' => $agent->device(),
'browser' => $agent->browser(), 'browser' => $agent->browser(),