unlockShipFeature
This commit is contained in:
parent
3370dc10e1
commit
a9cf95242c
18
src/controllers/api/unlockShipFeatureController.ts
Normal file
18
src/controllers/api/unlockShipFeatureController.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { RequestHandler } from "express";
|
||||||
|
import { unlockShipFeature } from "@/src/services/personalRoomsService";
|
||||||
|
import { parseString } from "@/src/helpers/general";
|
||||||
|
|
||||||
|
export interface IUnlockShipFeatureRequest {
|
||||||
|
Feature: string;
|
||||||
|
KeyChain: string;
|
||||||
|
ChainStage: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||||
|
export const unlockShipFeatureController: RequestHandler = async (req, res) => {
|
||||||
|
const accountId = parseString(req.query.accountId);
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
|
||||||
|
const shipFeatureRequest = JSON.parse(req.body as string) as IUnlockShipFeatureRequest;
|
||||||
|
await unlockShipFeature(accountId, shipFeatureRequest.Feature);
|
||||||
|
res.send([]);
|
||||||
|
};
|
@ -10,3 +10,10 @@ export const getPersonalRooms = async (accountId: string) => {
|
|||||||
}
|
}
|
||||||
return personalRooms;
|
return personalRooms;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const unlockShipFeature = async (accountId: string, shipFeature: string) => {
|
||||||
|
const personalRooms = await getPersonalRooms(accountId);
|
||||||
|
if (!personalRooms.Ship.Features.includes(shipFeature)) personalRooms.Ship.Features.push(shipFeature);
|
||||||
|
await personalRooms.save();
|
||||||
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user