mirror of
https://github.com/flarum/core.git
synced 2025-08-11 10:55:47 +02:00
Track user "last seen" time and display whether they are online or not
according to their preferences
This commit is contained in:
@@ -21,7 +21,10 @@ class LoginWithHeader
|
||||
if (starts_with($header, $this->prefix) &&
|
||||
($token = substr($header, strlen($this->prefix))) &&
|
||||
($accessToken = AccessToken::where('id', $token)->first())) {
|
||||
$this->actor->setUser($accessToken->user);
|
||||
$this->actor->setUser($user = $accessToken->user);
|
||||
|
||||
$user->last_seen_time = time();
|
||||
$user->save();
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
@@ -25,13 +25,18 @@ class UserSerializer extends UserBasicSerializer
|
||||
$attributes += [
|
||||
'bioHtml' => $user->bioHtml,
|
||||
'joinTime' => $user->join_time ? $user->join_time->toRFC3339String() : null,
|
||||
'lastSeenTime' => $user->last_seen_time ? $user->last_seen_time->toRFC3339String() : null,
|
||||
'discussionsCount' => (int) $user->discussions_count,
|
||||
'commentsCount' => (int) $user->comments_count,
|
||||
'canEdit' => $canEdit,
|
||||
'canDelete' => $user->can($actorUser, 'delete'),
|
||||
];
|
||||
|
||||
if ($user->preference('discloseOnline')) {
|
||||
$attributes += [
|
||||
'lastSeenTime' => $user->last_seen_time ? $user->last_seen_time->toRFC3339String() : null
|
||||
];
|
||||
}
|
||||
|
||||
if ($canEdit) {
|
||||
$attributes += [
|
||||
'bio' => $user->bio,
|
||||
|
Reference in New Issue
Block a user