From dd4c773553f6f4324db630a0dfe1de5c017bd4ea Mon Sep 17 00:00:00 2001 From: Mia <49593536+mia-pi-git@users.noreply.github.com> Date: Fri, 29 Aug 2025 17:23:44 -0500 Subject: [PATCH] Add replays/check-login endpoint --- src/actions.ts | 8 +++++++- src/server.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/actions.ts b/src/actions.ts index 9e267ef..58c13d8 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -11,7 +11,7 @@ import * as url from 'url'; import { Config } from './config-loader'; import { Ladder, type LadderEntry } from './ladder'; import { Replays } from './replays'; -import { ActionError, type QueryHandler, Server } from './server'; +import { ActionError, type QueryHandler, Server, DISPATCH_PREFIX} from './server'; import { Session } from './user'; import { toID, updateserver, bash, time, escapeHTML, signAsync, TimeSorter, @@ -1038,6 +1038,12 @@ export const actions: { [k: string]: QueryHandler } = { this.allowCORS(); return Replays.recent(); }, + 'replays/check-login'(params) { + return ( + DISPATCH_PREFIX + `${this.user.id},` + + `${Config.sysops.includes(this.user.id) ? 1 : ''}` + ); + }, async 'replays/search'(params) { this.allowCORS(); if (params.sort && params.sort !== 'rating' && params.sort !== 'date') { diff --git a/src/server.ts b/src/server.ts index a1a391f..9444f40 100644 --- a/src/server.ts +++ b/src/server.ts @@ -33,7 +33,7 @@ import IPTools from './ip-tools'; * Adding `]` to the beginning makes sure that the output is a syntax * error in JS, so treating it as a JS file will simply crash and fail. */ -const DISPATCH_PREFIX = ']'; +export const DISPATCH_PREFIX = ']'; /** * Throw this to end a request with an `actionerror` message.