mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 17:41:51 +00:00
fix(ci): decouple realtime presence and test Atlas fill indices
Bind the realtime activity port to the existing SessionsService at app startup to remove the domain import cycle. Check the Atlas mesh through its triangle indices because degenerate rings can leave vertices that never contribute to the fill.
This commit is contained in:
@@ -96,6 +96,7 @@ import { RoutingRelayModule } from './routing-relay/routing-relay.module';
|
||||
import { SchedulingModule } from './scheduling/scheduling.module';
|
||||
import { SchoolHolidaysModule } from './school-holidays/school-holidays.module';
|
||||
import { ServiceIdentityModule } from './service-identity/service-identity.module';
|
||||
import { SessionActivityModule } from './sessions/session-activity.module';
|
||||
import { SessionsModule } from './sessions/sessions.module';
|
||||
import { SettingsModule } from './settings/settings.module';
|
||||
import { ShareModule } from './share/share.module';
|
||||
@@ -130,6 +131,7 @@ import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core';
|
||||
RealtimeModule,
|
||||
RealtimeGatewayModule,
|
||||
JourneyAccessModule,
|
||||
SessionActivityModule,
|
||||
SchedulingModule,
|
||||
McpModule.forRoot({
|
||||
accessPolicy: trekMcpAccessPolicy,
|
||||
|
||||
@@ -4,7 +4,6 @@ import { Users } from '../../db/entities/Users.entity';
|
||||
import { EphemeralTokenModule } from '../auth-core/ephemeral-token.module';
|
||||
import { DatabaseLifecycleModule } from '../database/database-lifecycle.module';
|
||||
import { DatabaseLifecycle } from '../database/database-lifecycle.service';
|
||||
import { SessionsModule } from '../sessions/sessions.module';
|
||||
import { TripMembershipModule } from '../trip-membership/trip-membership.module';
|
||||
import { RealtimeGateway } from './realtime.gateway';
|
||||
import { closeSockets, processRooms, RoomRegistry, roomsSlot } from './ws-state';
|
||||
@@ -36,7 +35,6 @@ import { Module, type OnModuleDestroy } from '@nestjs/common';
|
||||
TripMembershipModule,
|
||||
EphemeralTokenModule,
|
||||
DatabaseLifecycleModule,
|
||||
SessionsModule,
|
||||
MikroOrmModule.forFeature([Users, AppSettings, Trips]),
|
||||
],
|
||||
// The room registry is the process-wide in-memory one; the constructor
|
||||
|
||||
@@ -10,9 +10,9 @@ import { EphemeralTokenService } from '../auth-core/ephemeral-token.service';
|
||||
import { SESSION_TOUCH_INTERVAL_MS } from '../auth-core/jwt-verify';
|
||||
import { readAppSetting } from '../common/app-settings.registry';
|
||||
import { toRowId } from '../common/row-id';
|
||||
import { SessionsService } from '../sessions/sessions.service';
|
||||
import { TripAccessService } from '../trip-membership/trip-access.service';
|
||||
import { JOURNEY_ACCESS, type JourneyAccess } from './journey-access.types';
|
||||
import { SESSION_ACTIVITY, type SessionActivity } from './session-activity.types';
|
||||
import {
|
||||
announceBookPeers,
|
||||
bookPeers,
|
||||
@@ -88,7 +88,7 @@ export class RealtimeGateway implements OnGatewayInit, OnGatewayConnection, OnGa
|
||||
@InjectRepository(AppSettings) private readonly appSettings: AppSettingsRepository,
|
||||
// A tab in front keeps its session's last activity current (presence below),
|
||||
// written through the sessions domain that owns the table.
|
||||
private readonly sessions: SessionsService,
|
||||
@Inject(SESSION_ACTIVITY) private readonly sessionActivity: SessionActivity,
|
||||
// Room membership, behind its port. The container's provider, which
|
||||
// RealtimeGatewayModule also installs for the broadcast functions in
|
||||
// ws-state.ts; a hand-built gateway takes the installed one.
|
||||
@@ -236,7 +236,7 @@ export class RealtimeGateway implements OnGatewayInit, OnGatewayConnection, OnGa
|
||||
if (now - (this.touchedAt.get(socket) ?? 0) < SESSION_TOUCH_INTERVAL_MS) return;
|
||||
this.touchedAt.set(socket, now);
|
||||
try {
|
||||
await this.sessions.touchLastSeen(session, dbNow(new Date(now)));
|
||||
await this.sessionActivity.touchLastSeen(session, dbNow(new Date(now)));
|
||||
} catch (err) {
|
||||
// Bookkeeping for the user list only: a busy database must not cost the socket.
|
||||
logError(`ws presence touch failed: ${err instanceof Error ? err.message : String(err)}`);
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export const SESSION_ACTIVITY = Symbol('SESSION_ACTIVITY');
|
||||
|
||||
/** Persists the activity reported by a visible WebSocket tab. */
|
||||
export interface SessionActivity {
|
||||
touchLastSeen(sessionId: string, now: string): Promise<void>;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { SESSION_ACTIVITY } from '../realtime/session-activity.types';
|
||||
import { SessionsModule } from './sessions.module';
|
||||
import { SessionsService } from './sessions.service';
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
|
||||
/** Binds the gateway's activity port to the existing session service. */
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [SessionsModule],
|
||||
providers: [{ provide: SESSION_ACTIVITY, useExisting: SessionsService }],
|
||||
exports: [SESSION_ACTIVITY],
|
||||
})
|
||||
export class SessionActivityModule {}
|
||||
Reference in New Issue
Block a user