feat: Add game activity status (Experimental)
All checks were successful
Queue Release Build / prepare (push) Successful in 23s
Deploy Web Apps / deploy (push) Successful in 5m54s
Queue Release Build / build-windows (push) Successful in 16m19s
Queue Release Build / build-linux (push) Successful in 30m13s
Queue Release Build / finalize (push) Successful in 47s

This commit is contained in:
2026-04-27 05:46:33 +02:00
parent 3858beb28e
commit 53389ed3ad
50 changed files with 2007 additions and 104 deletions

View File

@@ -157,6 +157,14 @@ describe('ServerEndpointStateService', () => {
expect(service.servers().find((candidate) => candidate.id === endpoint.id)?.isActive).toBe(true);
});
it('resolves legacy https source URLs to the local http default endpoint on the same host', () => {
const defaultServer = getConfiguredDefaultServer('default');
const service = createService();
const legacyHttpsUrl = defaultServer.url?.replace(/^http:\/\//, 'https://') ?? '';
expect(service.findServerByUrl(legacyHttpsUrl)?.url).toBe(defaultServer.url);
});
it('persists turning a configured default endpoint off and back on', () => {
const defaultServer = getConfiguredDefaultServer('toju-primary');
const service = createService();

View File

@@ -117,8 +117,9 @@ export class ServerEndpointStateService {
findServerByUrl(url: string): ServerEndpoint | undefined {
const sanitisedUrl = this.sanitiseUrl(url);
const exactEndpoint = this._servers().find((endpoint) => this.sanitiseUrl(endpoint.url) === sanitisedUrl);
return this._servers().find((endpoint) => this.sanitiseUrl(endpoint.url) === sanitisedUrl);
return exactEndpoint ?? this.findHttpEndpointForHttpsUrl(sanitisedUrl);
}
resolveCanonicalEndpoint(endpoint: ServerEndpoint | null | undefined): ServerEndpoint | null {
@@ -447,4 +448,28 @@ export class ServerEndpointStateService {
return false;
}
}
private findHttpEndpointForHttpsUrl(url: string): ServerEndpoint | undefined {
const requestedUrl = this.parseUrl(url);
if (requestedUrl?.protocol !== 'https:') {
return undefined;
}
return this._servers().find((endpoint) => {
const endpointUrl = this.parseUrl(endpoint.url);
return endpointUrl?.protocol === 'http:'
&& endpointUrl.hostname === requestedUrl.hostname
&& endpointUrl.port === requestedUrl.port;
});
}
private parseUrl(url: string): URL | null {
try {
return new URL(url);
} catch {
return null;
}
}
}

View File

@@ -8,7 +8,11 @@ import {
of,
throwError
} from 'rxjs';
import { catchError, map, scan } from 'rxjs/operators';
import {
catchError,
map,
scan
} from 'rxjs/operators';
import {
ChannelPermissionOverride,
type Channel,
@@ -32,6 +36,19 @@ import type {
} from '../../domain/models/server-directory.model';
import type { RoomSignalSourceInput } from '../../domain/logic/room-signal-source.logic';
interface ServerLookupError {
status?: number;
error?: {
errorCode?: unknown;
};
}
function isServerNotFoundError(error: unknown): boolean {
const lookupError = error as ServerLookupError;
return lookupError?.status === 404 && lookupError.error?.errorCode === 'SERVER_NOT_FOUND';
}
@Injectable({ providedIn: 'root' })
export class ServerDirectoryApiService {
private readonly http = inject(HttpClient);
@@ -90,6 +107,10 @@ export class ServerDirectoryApiService {
return this.http.get<ServerInfo>(`${this.getApiBaseUrl(selector)}/servers/${serverId}`).pipe(
map((server) => this.normalizeServerInfo(server, this.resolveEndpoint(selector))),
catchError((error) => {
if (isServerNotFoundError(error)) {
return of(null);
}
console.error('Failed to get server:', error);
return of(null);
})