관리자 사용자 목록: 게스트 삭제 예정 시각 표시
게스트는 사이트를 나가고 하루 지나면 자동 삭제된다. 목록과 상세에 마지막 접속 + 24시간을 보여 주고, 접속 중이거나 방에 자리가 있으면 삭제 보류로 표시한다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -64,11 +64,12 @@ export function startServer(opts: StartOptions) {
|
||||
gateway.closeUser(id);
|
||||
if (users.deleteGuest(id)) log('info', 'guest removed', { user: id });
|
||||
};
|
||||
/** Still on the site (socket open) or still holding a seat: not idle. */
|
||||
const guestKept = (id: string) => gateway.isOnline(id) || !!rooms.activeRoomFor(id);
|
||||
/** Guests who closed the site and stayed away a day are deleted (docs/05 §4). */
|
||||
const purgeIdleGuests = (now = Date.now()) => {
|
||||
for (const id of users.idleGuests(now - GUEST_IDLE_MS)) {
|
||||
// Still on the site (socket open) or still holding a seat: not idle.
|
||||
if (gateway.isOnline(id) || rooms.activeRoomFor(id)) continue;
|
||||
if (guestKept(id)) continue;
|
||||
removeGuest(id);
|
||||
}
|
||||
};
|
||||
@@ -95,6 +96,7 @@ export function startServer(opts: StartOptions) {
|
||||
audit,
|
||||
games: GAMES,
|
||||
disconnectUser: (id) => gateway.disconnectUser(id),
|
||||
guestDeleteAt: (u) => (u.kind !== 'guest' || guestKept(u.id) ? null : u.last_seen_at + GUEST_IDLE_MS),
|
||||
stats: () => {
|
||||
const all = rooms.all();
|
||||
const day = Date.now() - 24 * 3600_000;
|
||||
|
||||
Reference in New Issue
Block a user