Add replays/check-login endpoint
Some checks failed
Node.js CI / build (22.x) (push) Has been cancelled

This commit is contained in:
Mia 2025-08-29 17:23:44 -05:00
parent ca6d979e5a
commit dd4c773553
2 changed files with 8 additions and 2 deletions

View File

@ -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') {

View File

@ -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.