mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update AccountService, add setLastActive method
This commit is contained in:
parent
85839b220a
commit
ebbd98e743
1 changed files with 195 additions and 181 deletions
|
@ -166,7 +166,7 @@ class AccountService
|
|||
public static function usernameToId($username)
|
||||
{
|
||||
$key = self::CACHE_KEY . 'u2id:' . hash('sha256', $username);
|
||||
return Cache::remember($key, 900, function() use($username) {
|
||||
return Cache::remember($key, 14400, function() use($username) {
|
||||
$s = Str::of($username);
|
||||
if($s->contains('@') && !$s->startsWith('@')) {
|
||||
$username = "@{$username}";
|
||||
|
@ -220,4 +220,18 @@ class AccountService
|
|||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public static function setLastActive($id = false)
|
||||
{
|
||||
if(!$id) { return; }
|
||||
$key = 'user:last_active_at:id:' . $id;
|
||||
if(!Cache::has($key)) {
|
||||
$user = User::find($id);
|
||||
if(!$user) { return; }
|
||||
$user->last_active_at = now();
|
||||
$user->save();
|
||||
Cache::put($key, 1, 14400);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue