forked from OpenWF/SpaceNinjaServer
feat: implement tauntHistory.php (#441)
This commit is contained in:
parent
543d94e88e
commit
76bff65d92
22
src/controllers/api/tauntHistoryController.ts
Normal file
22
src/controllers/api/tauntHistoryController.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { getAccountIdForRequest } from "@/src/services/loginService";
|
||||
import { getInventory } from "@/src/services/inventoryService";
|
||||
import { ITaunt } from "@/src/types/inventoryTypes/inventoryTypes";
|
||||
import { logger } from "@/src/utils/logger";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
export const tauntHistoryController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const inventory = await getInventory(accountId);
|
||||
const clientTaunt = JSON.parse(String(req.body)) as ITaunt;
|
||||
logger.debug(`updating taunt ${clientTaunt.node} to state ${clientTaunt.state}`);
|
||||
inventory.TauntHistory ??= [];
|
||||
const taunt = inventory.TauntHistory.find(x => x.node == clientTaunt.node);
|
||||
if (taunt) {
|
||||
taunt.state = clientTaunt.state;
|
||||
} else {
|
||||
inventory.TauntHistory.push(clientTaunt);
|
||||
}
|
||||
await inventory.save();
|
||||
res.end();
|
||||
};
|
@ -32,7 +32,7 @@ import {
|
||||
IFusionTreasure,
|
||||
ISpectreLoadout,
|
||||
IWeaponSkinDatabase,
|
||||
ITauntHistory,
|
||||
ITaunt,
|
||||
IPeriodicMissionCompletionDatabase,
|
||||
IPeriodicMissionCompletionResponse,
|
||||
ILoreFragmentScan,
|
||||
@ -533,7 +533,7 @@ weaponSkinsSchema.set("toJSON", {
|
||||
}
|
||||
});
|
||||
|
||||
const tauntHistorySchema = new Schema<ITauntHistory>(
|
||||
const tauntSchema = new Schema<ITaunt>(
|
||||
{
|
||||
node: String,
|
||||
state: String
|
||||
@ -772,8 +772,8 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
|
||||
|
||||
//Ayatan Item
|
||||
FusionTreasures: [fusionTreasuresSchema],
|
||||
//"node": "TreasureTutorial", "state": "TS_COMPLETED"
|
||||
TauntHistory: [tauntHistorySchema],
|
||||
//only used for Maroo apparently - { "node": "TreasureTutorial", "state": "TS_COMPLETED" }
|
||||
TauntHistory: { type: [tauntSchema], default: undefined },
|
||||
|
||||
//noShow2FA,VisitPrimeVault etc
|
||||
WebFlags: Schema.Types.Mixed,
|
||||
|
@ -22,6 +22,7 @@ import { getIgnoredUsersController } from "@/src/controllers/api/getIgnoredUsers
|
||||
import { getNewRewardSeedController } from "@/src/controllers/api/getNewRewardSeedController";
|
||||
import { getShipController } from "@/src/controllers/api/getShipController";
|
||||
import { getVendorInfoController } from "@/src/controllers/api/getVendorInfoController";
|
||||
import { gildWeaponController } from "@/src/controllers/api/gildWeaponController";
|
||||
import { guildTechController } from "../controllers/api/guildTechController";
|
||||
import { hostSessionController } from "@/src/controllers/api/hostSessionController";
|
||||
import { hubController } from "@/src/controllers/api/hubController";
|
||||
@ -56,12 +57,12 @@ import { startRecipeController } from "@/src/controllers/api/startRecipeControll
|
||||
import { stepSequencersController } from "@/src/controllers/api/stepSequencersController";
|
||||
import { surveysController } from "@/src/controllers/api/surveysController";
|
||||
import { syndicateSacrificeController } from "../controllers/api/syndicateSacrificeController";
|
||||
import { tauntHistoryController } from "@/src/controllers/api/tauntHistoryController";
|
||||
import { trainingResultController } from "@/src/controllers/api/trainingResultController";
|
||||
import { updateChallengeProgressController } from "@/src/controllers/api/updateChallengeProgressController";
|
||||
import { updateSessionGetController, updateSessionPostController } from "@/src/controllers/api/updateSessionController";
|
||||
import { updateThemeController } from "../controllers/api/updateThemeController";
|
||||
import { upgradesController } from "@/src/controllers/api/upgradesController";
|
||||
import { gildWeaponController } from "../controllers/api/gildWeaponController";
|
||||
|
||||
const apiRouter = express.Router();
|
||||
|
||||
@ -128,6 +129,7 @@ apiRouter.post("/startDojoRecipe.php", startDojoRecipeController);
|
||||
apiRouter.post("/startRecipe.php", startRecipeController);
|
||||
apiRouter.post("/stepSequencers.php", stepSequencersController);
|
||||
apiRouter.post("/syndicateSacrifice.php", syndicateSacrificeController);
|
||||
apiRouter.post("/tauntHistory.php", tauntHistoryController);
|
||||
apiRouter.post("/trainingResult.php", trainingResultController);
|
||||
apiRouter.post("/updateChallengeProgress.php", updateChallengeProgressController);
|
||||
apiRouter.post("/updateSession.php", updateSessionPostController);
|
||||
|
@ -177,7 +177,7 @@ export interface IInventoryResponse {
|
||||
CompletedAlerts: string[];
|
||||
Consumables: IConsumable[];
|
||||
LevelKeys: IConsumable[];
|
||||
TauntHistory: ITauntHistory[];
|
||||
TauntHistory?: ITaunt[];
|
||||
StoryModeChoice: string;
|
||||
PeriodicMissionCompletions: IPeriodicMissionCompletionDatabase[];
|
||||
KubrowPetEggs: IKubrowPetEgg[];
|
||||
@ -880,9 +880,9 @@ export interface INotePacks {
|
||||
PERCUSSION: string;
|
||||
}
|
||||
|
||||
export interface ITauntHistory {
|
||||
export interface ITaunt {
|
||||
node: string;
|
||||
state: string;
|
||||
state: "TS_UNLOCKED" | "TS_COMPLETED";
|
||||
}
|
||||
|
||||
export interface IWeaponSkinDatabase {
|
||||
|
Loading…
x
Reference in New Issue
Block a user