feat: setHubNpcCustomizations
This commit is contained in:
		
							parent
							
								
									218df461e1
								
							
						
					
					
						commit
						2fef072ca9
					
				
							
								
								
									
										21
									
								
								src/controllers/api/setHubNpcCustomizationsController.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/controllers/api/setHubNpcCustomizationsController.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,21 @@
 | 
				
			|||||||
 | 
					import { getJSONfromString } from "@/src/helpers/stringHelpers";
 | 
				
			||||||
 | 
					import { getInventory } from "@/src/services/inventoryService";
 | 
				
			||||||
 | 
					import { getAccountIdForRequest } from "@/src/services/loginService";
 | 
				
			||||||
 | 
					import { IHubNpcCustomization } from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
 | 
					import { RequestHandler } from "express";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const setHubNpcCustomizationsController: RequestHandler = async (req, res) => {
 | 
				
			||||||
 | 
					    const accountId = await getAccountIdForRequest(req);
 | 
				
			||||||
 | 
					    const inventory = await getInventory(accountId, "HubNpcCustomizations");
 | 
				
			||||||
 | 
					    const upload = getJSONfromString<IHubNpcCustomization>(String(req.body));
 | 
				
			||||||
 | 
					    inventory.HubNpcCustomizations ??= [];
 | 
				
			||||||
 | 
					    const cust = inventory.HubNpcCustomizations.find(x => x.Tag == upload.Tag);
 | 
				
			||||||
 | 
					    if (cust) {
 | 
				
			||||||
 | 
					        cust.Colors = upload.Colors;
 | 
				
			||||||
 | 
					        cust.Pattern = upload.Pattern;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        inventory.HubNpcCustomizations.push(upload);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    await inventory.save();
 | 
				
			||||||
 | 
					    res.end();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@ -95,7 +95,8 @@ import {
 | 
				
			|||||||
    ISortieRewardAttenuation,
 | 
					    ISortieRewardAttenuation,
 | 
				
			||||||
    IInvasionProgressDatabase,
 | 
					    IInvasionProgressDatabase,
 | 
				
			||||||
    IInvasionProgressClient,
 | 
					    IInvasionProgressClient,
 | 
				
			||||||
    IAccolades
 | 
					    IAccolades,
 | 
				
			||||||
 | 
					    IHubNpcCustomization
 | 
				
			||||||
} from "../../types/inventoryTypes/inventoryTypes";
 | 
					} from "../../types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
import { IOid } from "../../types/commonTypes";
 | 
					import { IOid } from "../../types/commonTypes";
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
@ -1327,6 +1328,15 @@ const lockedWeaponGroupSchema = new Schema<ILockedWeaponGroupDatabase>(
 | 
				
			|||||||
    { _id: false }
 | 
					    { _id: false }
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const hubNpcCustomizationSchema = new Schema<IHubNpcCustomization>(
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        Colors: colorSchema,
 | 
				
			||||||
 | 
					        Pattern: String,
 | 
				
			||||||
 | 
					        Tag: String
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    { _id: false }
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
 | 
					const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        accountOwnerId: Schema.Types.ObjectId,
 | 
					        accountOwnerId: Schema.Types.ObjectId,
 | 
				
			||||||
@ -1680,7 +1690,9 @@ const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        // G3 + Zanuka
 | 
					        // G3 + Zanuka
 | 
				
			||||||
        BrandedSuits: { type: [Schema.Types.ObjectId], default: undefined },
 | 
					        BrandedSuits: { type: [Schema.Types.ObjectId], default: undefined },
 | 
				
			||||||
        LockedWeaponGroup: { type: lockedWeaponGroupSchema, default: undefined }
 | 
					        LockedWeaponGroup: { type: lockedWeaponGroupSchema, default: undefined },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        HubNpcCustomizations: { type: [hubNpcCustomizationSchema], default: undefined }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    { timestamps: { createdAt: "Created", updatedAt: false } }
 | 
					    { timestamps: { createdAt: "Created", updatedAt: false } }
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
				
			|||||||
@ -117,6 +117,7 @@ import { setDojoComponentMessageController } from "@/src/controllers/api/setDojo
 | 
				
			|||||||
import { setDojoComponentSettingsController } from "@/src/controllers/api/setDojoComponentSettingsController";
 | 
					import { setDojoComponentSettingsController } from "@/src/controllers/api/setDojoComponentSettingsController";
 | 
				
			||||||
import { setEquippedInstrumentController } from "@/src/controllers/api/setEquippedInstrumentController";
 | 
					import { setEquippedInstrumentController } from "@/src/controllers/api/setEquippedInstrumentController";
 | 
				
			||||||
import { setGuildMotdController } from "@/src/controllers/api/setGuildMotdController";
 | 
					import { setGuildMotdController } from "@/src/controllers/api/setGuildMotdController";
 | 
				
			||||||
 | 
					import { setHubNpcCustomizationsController } from "@/src/controllers/api/setHubNpcCustomizationsController";
 | 
				
			||||||
import { setPlacedDecoInfoController } from "@/src/controllers/api/setPlacedDecoInfoController";
 | 
					import { setPlacedDecoInfoController } from "@/src/controllers/api/setPlacedDecoInfoController";
 | 
				
			||||||
import { setShipCustomizationsController } from "@/src/controllers/api/setShipCustomizationsController";
 | 
					import { setShipCustomizationsController } from "@/src/controllers/api/setShipCustomizationsController";
 | 
				
			||||||
import { setShipFavouriteLoadoutController } from "@/src/controllers/api/setShipFavouriteLoadoutController";
 | 
					import { setShipFavouriteLoadoutController } from "@/src/controllers/api/setShipFavouriteLoadoutController";
 | 
				
			||||||
@ -285,6 +286,7 @@ apiRouter.post("/setDojoComponentMessage.php", setDojoComponentMessageController
 | 
				
			|||||||
apiRouter.post("/setDojoComponentSettings.php", setDojoComponentSettingsController);
 | 
					apiRouter.post("/setDojoComponentSettings.php", setDojoComponentSettingsController);
 | 
				
			||||||
apiRouter.post("/setEquippedInstrument.php", setEquippedInstrumentController);
 | 
					apiRouter.post("/setEquippedInstrument.php", setEquippedInstrumentController);
 | 
				
			||||||
apiRouter.post("/setGuildMotd.php", setGuildMotdController);
 | 
					apiRouter.post("/setGuildMotd.php", setGuildMotdController);
 | 
				
			||||||
 | 
					apiRouter.post("/setHubNpcCustomizations.php", setHubNpcCustomizationsController);
 | 
				
			||||||
apiRouter.post("/setPlacedDecoInfo.php", setPlacedDecoInfoController);
 | 
					apiRouter.post("/setPlacedDecoInfo.php", setPlacedDecoInfoController);
 | 
				
			||||||
apiRouter.post("/setShipCustomizations.php", setShipCustomizationsController);
 | 
					apiRouter.post("/setShipCustomizations.php", setShipCustomizationsController);
 | 
				
			||||||
apiRouter.post("/setShipFavouriteLoadout.php", setShipFavouriteLoadoutController);
 | 
					apiRouter.post("/setShipFavouriteLoadout.php", setShipFavouriteLoadoutController);
 | 
				
			||||||
 | 
				
			|||||||
@ -368,6 +368,7 @@ export interface IInventoryClient extends IDailyAffiliations, InventoryClientEqu
 | 
				
			|||||||
    EchoesHexConquestActiveStickers?: string[];
 | 
					    EchoesHexConquestActiveStickers?: string[];
 | 
				
			||||||
    BrandedSuits?: IOid[];
 | 
					    BrandedSuits?: IOid[];
 | 
				
			||||||
    LockedWeaponGroup?: ILockedWeaponGroupClient;
 | 
					    LockedWeaponGroup?: ILockedWeaponGroupClient;
 | 
				
			||||||
 | 
					    HubNpcCustomizations?: IHubNpcCustomization[];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IAffiliation {
 | 
					export interface IAffiliation {
 | 
				
			||||||
@ -1228,3 +1229,9 @@ export interface ILockedWeaponGroupDatabase {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type TPartialStartingGear = Pick<IInventoryClient, "LongGuns" | "Suits" | "Pistols" | "Melee">;
 | 
					export type TPartialStartingGear = Pick<IInventoryClient, "LongGuns" | "Suits" | "Pistols" | "Melee">;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface IHubNpcCustomization {
 | 
				
			||||||
 | 
					    Colors?: IColor;
 | 
				
			||||||
 | 
					    Pattern: string;
 | 
				
			||||||
 | 
					    Tag: string;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user