forked from OpenWF/SpaceNinjaServer
Re #2361. Mostly done via ChatGPT Codex. Reviewed-on: OpenWF/SpaceNinjaServer#2738 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
20 lines
774 B
TypeScript
20 lines
774 B
TypeScript
import type { RequestHandler } from "express";
|
|
import allShipFeatures from "../../../static/fixed_responses/allShipFeatures.json" with { type: "json" };
|
|
import { getAccountIdForRequest } from "../../services/loginService.ts";
|
|
import { getPersonalRooms } from "../../services/personalRoomsService.ts";
|
|
|
|
export const unlockAllShipFeaturesController: RequestHandler = async (req, res) => {
|
|
const accountId = await getAccountIdForRequest(req);
|
|
const personalRooms = await getPersonalRooms(accountId);
|
|
|
|
const featureSet = new Set(personalRooms.Ship.Features);
|
|
for (const feature of allShipFeatures) {
|
|
if (!featureSet.has(feature)) {
|
|
personalRooms.Ship.Features.push(feature);
|
|
}
|
|
}
|
|
|
|
await personalRooms.save();
|
|
res.end();
|
|
};
|