feat: 外部のサーバでも最終更新時刻からオンライン状況を推定
This commit is contained in:
parent
46e5192de1
commit
9132e2c701
@ -376,8 +376,9 @@ export class UserEntityService implements OnModuleInit {
|
|||||||
@bindThis
|
@bindThis
|
||||||
public getOnlineStatus(user: MiUser): 'unknown' | 'online' | 'active' | 'offline' {
|
public getOnlineStatus(user: MiUser): 'unknown' | 'online' | 'active' | 'offline' {
|
||||||
if (user.hideOnlineStatus) return 'unknown';
|
if (user.hideOnlineStatus) return 'unknown';
|
||||||
if (user.lastActiveDate == null) return 'unknown';
|
const activeDate = user.lastActiveDate ?? user.updatedAt
|
||||||
const elapsed = Date.now() - user.lastActiveDate.getTime();
|
if (activeDate == null) return 'unknown';
|
||||||
|
const elapsed = Date.now() - activeDate.getTime();
|
||||||
return (
|
return (
|
||||||
elapsed < USER_ONLINE_THRESHOLD ? 'online' :
|
elapsed < USER_ONLINE_THRESHOLD ? 'online' :
|
||||||
elapsed < USER_ACTIVE_THRESHOLD ? 'active' :
|
elapsed < USER_ACTIVE_THRESHOLD ? 'active' :
|
||||||
|
Loading…
Reference in New Issue
Block a user