Files
djhackersdev_minime/src/idz/handler/saveTimeAttack.ts
T
Tau c2b0bcabc4 idz: Remove profile ext id
Turns out (while researching team creation) the profile ext id
is just the aime id. After creating a team a profile discovery
request is immediately issued with the "profile id" in the field
that holds the aime id during initial profile load.
2019-11-06 17:28:30 -05:00

26 lines
789 B
TypeScript

import { SaveTimeAttackRequest } from "../request/saveTimeAttack";
import { SaveTimeAttackResponse } from "../response/saveTimeAttack";
import { Repositories } from "../repo";
export async function saveTimeAttack(
w: Repositories,
req: SaveTimeAttackRequest
): Promise<SaveTimeAttackResponse> {
// Non time-attack credits still call this method, but they pass some
// bullshit payload that we need to ignore.
if (req.payload.totalTime > 0) {
// Override client time since we might be doing some maintenance window
// avoidance time warping stuff
const now = new Date();
const profileId = await w.profile().find(req.aimeId);
await w.timeAttack().save(profileId, { ...req.payload, timestamp: now });
}
return {
type: "save_time_attack_res",
};
}