respect IEmailItem.sendOnlyOnce
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build / build (20) (push) Successful in 41s
				
			
		
			
				
	
				Build / build (18) (push) Successful in 59s
				
			
		
			
				
	
				Build / build (18) (pull_request) Successful in 41s
				
			
		
			
				
	
				Build / build (20) (pull_request) Successful in 59s
				
			
		
			
				
	
				Build / build (22) (pull_request) Successful in 40s
				
			
		
			
				
	
				Build / build (22) (push) Successful in 36s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build / build (20) (push) Successful in 41s
				
			Build / build (18) (push) Successful in 59s
				
			Build / build (18) (pull_request) Successful in 41s
				
			Build / build (20) (pull_request) Successful in 59s
				
			Build / build (22) (pull_request) Successful in 40s
				
			Build / build (22) (push) Successful in 36s
				
			This commit is contained in:
		
							parent
							
								
									1341b71177
								
							
						
					
					
						commit
						26ad8fceff
					
				@ -54,7 +54,7 @@ export const missionInventoryUpdateController: RequestHandler = async (req, res)
 | 
				
			|||||||
    logger.debug("mission report:", missionReport);
 | 
					    logger.debug("mission report:", missionReport);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const inventory = await getInventory(accountId);
 | 
					    const inventory = await getInventory(accountId);
 | 
				
			||||||
    const inventoryUpdates = addMissionInventoryUpdates(inventory, missionReport);
 | 
					    const inventoryUpdates = await addMissionInventoryUpdates(inventory, missionReport);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (missionReport.MissionStatus !== "GS_SUCCESS") {
 | 
					    if (missionReport.MissionStatus !== "GS_SUCCESS") {
 | 
				
			||||||
        await inventory.save();
 | 
					        await inventory.save();
 | 
				
			||||||
 | 
				
			|||||||
@ -428,10 +428,8 @@ export const addItem = async (
 | 
				
			|||||||
        };
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (typeName in ExportEmailItems) {
 | 
					    if (typeName in ExportEmailItems) {
 | 
				
			||||||
        const emailItem = ExportEmailItems[typeName];
 | 
					 | 
				
			||||||
        await createMessage(inventory.accountOwnerId.toString(), [convertInboxMessage(emailItem.message)]);
 | 
					 | 
				
			||||||
        return {
 | 
					        return {
 | 
				
			||||||
            InventoryChanges: {}
 | 
					            InventoryChanges: await addEmailItem(inventory, typeName)
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -943,6 +941,23 @@ const addDrone = (
 | 
				
			|||||||
    return inventoryChanges;
 | 
					    return inventoryChanges;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const addEmailItem = async (
 | 
				
			||||||
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
 | 
					    typeName: string,
 | 
				
			||||||
 | 
					    inventoryChanges: IInventoryChanges = {}
 | 
				
			||||||
 | 
					): Promise<IInventoryChanges> => {
 | 
				
			||||||
 | 
					    const emailItem = ExportEmailItems[typeName];
 | 
				
			||||||
 | 
					    if (!emailItem.sendOnlyOnce || !inventory.EmailItems.find(x => x.ItemType == typeName)) {
 | 
				
			||||||
 | 
					        await createMessage(inventory.accountOwnerId.toString(), [convertInboxMessage(emailItem.message)]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        inventory.EmailItems.push({ ItemType: typeName, ItemCount: 1 });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        inventoryChanges.EmailItems ??= [];
 | 
				
			||||||
 | 
					        inventoryChanges.EmailItems.push({ ItemType: typeName, ItemCount: 1 });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return inventoryChanges;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//TODO: wrong id is not erroring
 | 
					//TODO: wrong id is not erroring
 | 
				
			||||||
export const addGearExpByCategory = (
 | 
					export const addGearExpByCategory = (
 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,4 @@
 | 
				
			|||||||
import {
 | 
					import {
 | 
				
			||||||
    ExportEmailItems,
 | 
					 | 
				
			||||||
    ExportFusionBundles,
 | 
					    ExportFusionBundles,
 | 
				
			||||||
    ExportRegions,
 | 
					    ExportRegions,
 | 
				
			||||||
    ExportRewards,
 | 
					    ExportRewards,
 | 
				
			||||||
@ -15,6 +14,7 @@ import {
 | 
				
			|||||||
    addConsumables,
 | 
					    addConsumables,
 | 
				
			||||||
    addCrewShipAmmo,
 | 
					    addCrewShipAmmo,
 | 
				
			||||||
    addCrewShipRawSalvage,
 | 
					    addCrewShipRawSalvage,
 | 
				
			||||||
 | 
					    addEmailItem,
 | 
				
			||||||
    addFocusXpIncreases,
 | 
					    addFocusXpIncreases,
 | 
				
			||||||
    addFusionTreasures,
 | 
					    addFusionTreasures,
 | 
				
			||||||
    addGearExpByCategory,
 | 
					    addGearExpByCategory,
 | 
				
			||||||
@ -28,7 +28,7 @@ import {
 | 
				
			|||||||
import { updateQuestKey } from "@/src/services/questService";
 | 
					import { updateQuestKey } from "@/src/services/questService";
 | 
				
			||||||
import { HydratedDocument } from "mongoose";
 | 
					import { HydratedDocument } from "mongoose";
 | 
				
			||||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
					import { IInventoryChanges } from "@/src/types/purchaseTypes";
 | 
				
			||||||
import { convertInboxMessage, getLevelKeyRewards, getNode } from "@/src/services/itemDataService";
 | 
					import { getLevelKeyRewards, getNode } from "@/src/services/itemDataService";
 | 
				
			||||||
import { InventoryDocumentProps, TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
 | 
					import { InventoryDocumentProps, TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel";
 | 
				
			||||||
import { getEntriesUnsafe } from "@/src/utils/ts-utils";
 | 
					import { getEntriesUnsafe } from "@/src/utils/ts-utils";
 | 
				
			||||||
import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
					import { IEquipmentClient } from "@/src/types/inventoryTypes/commonInventoryTypes";
 | 
				
			||||||
@ -62,10 +62,10 @@ const getRandomRewardByChance = (pool: IReward[]): IRngResult | undefined => {
 | 
				
			|||||||
//type TignoredInventoryUpdateKeys = (typeof ignoredInventoryUpdateKeys)[number];
 | 
					//type TignoredInventoryUpdateKeys = (typeof ignoredInventoryUpdateKeys)[number];
 | 
				
			||||||
//const knownUnhandledKeys: readonly string[] = ["test"] as const; // for unimplemented but important keys
 | 
					//const knownUnhandledKeys: readonly string[] = ["test"] as const; // for unimplemented but important keys
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const addMissionInventoryUpdates = (
 | 
					export const addMissionInventoryUpdates = async (
 | 
				
			||||||
    inventory: HydratedDocument<IInventoryDatabase, InventoryDocumentProps>,
 | 
					    inventory: HydratedDocument<IInventoryDatabase, InventoryDocumentProps>,
 | 
				
			||||||
    inventoryUpdates: IMissionInventoryUpdateRequest
 | 
					    inventoryUpdates: IMissionInventoryUpdateRequest
 | 
				
			||||||
): Partial<IInventoryDatabase> | undefined => {
 | 
					): Promise<Partial<IInventoryDatabase> | undefined> => {
 | 
				
			||||||
    //TODO: type this properly
 | 
					    //TODO: type this properly
 | 
				
			||||||
    const inventoryChanges: Partial<IInventoryDatabase> = {};
 | 
					    const inventoryChanges: Partial<IInventoryDatabase> = {};
 | 
				
			||||||
    if (inventoryUpdates.MissionFailed === true) {
 | 
					    if (inventoryUpdates.MissionFailed === true) {
 | 
				
			||||||
@ -158,10 +158,9 @@ export const addMissionInventoryUpdates = (
 | 
				
			|||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            case "EmailItems": {
 | 
					            case "EmailItems": {
 | 
				
			||||||
                value.forEach(tc => {
 | 
					                for (const tc of value) {
 | 
				
			||||||
                    const emailItem = ExportEmailItems[tc.ItemType];
 | 
					                    await addEmailItem(inventory, tc.ItemType);
 | 
				
			||||||
                    void createMessage(inventory.accountOwnerId.toString(), [convertInboxMessage(emailItem.message)]);
 | 
					                }
 | 
				
			||||||
                });
 | 
					 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            case "FocusXpIncreases": {
 | 
					            case "FocusXpIncreases": {
 | 
				
			||||||
@ -214,32 +213,32 @@ export const addMissionInventoryUpdates = (
 | 
				
			|||||||
                });
 | 
					                });
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case "CollectibleScans":
 | 
					            case "CollectibleScans":
 | 
				
			||||||
                value.forEach(scan => {
 | 
					                for (const scan of value) {
 | 
				
			||||||
                    const entry = inventory.CollectibleSeries?.find(x => x.CollectibleType == scan.CollectibleType);
 | 
					                    const entry = inventory.CollectibleSeries?.find(x => x.CollectibleType == scan.CollectibleType);
 | 
				
			||||||
                    if (entry) {
 | 
					                    if (entry) {
 | 
				
			||||||
                        entry.Count = scan.Count;
 | 
					                        entry.Count = scan.Count;
 | 
				
			||||||
                        entry.Tracking = scan.Tracking;
 | 
					                        entry.Tracking = scan.Tracking;
 | 
				
			||||||
                        if (entry.CollectibleType == "/Lotus/Objects/Orokin/Props/CollectibleSeriesOne") {
 | 
					                        if (entry.CollectibleType == "/Lotus/Objects/Orokin/Props/CollectibleSeriesOne") {
 | 
				
			||||||
                            const progress = entry.Count / entry.ReqScans;
 | 
					                            const progress = entry.Count / entry.ReqScans;
 | 
				
			||||||
                            entry.IncentiveStates.forEach(gate => {
 | 
					                            for (const gate of entry.IncentiveStates) {
 | 
				
			||||||
                                gate.complete = progress >= gate.threshold;
 | 
					                                gate.complete = progress >= gate.threshold;
 | 
				
			||||||
                                if (gate.complete && !gate.sent) {
 | 
					                                if (gate.complete && !gate.sent) {
 | 
				
			||||||
                                    gate.sent = true;
 | 
					                                    gate.sent = true;
 | 
				
			||||||
                                    if (gate.threshold == 0.5) {
 | 
					                                    if (gate.threshold == 0.5) {
 | 
				
			||||||
                                        void createMessage(inventory.accountOwnerId.toString(), [kuriaMessage50]);
 | 
					                                        await createMessage(inventory.accountOwnerId.toString(), [kuriaMessage50]);
 | 
				
			||||||
                                    } else {
 | 
					                                    } else {
 | 
				
			||||||
                                        void createMessage(inventory.accountOwnerId.toString(), [kuriaMessage75]);
 | 
					                                        await createMessage(inventory.accountOwnerId.toString(), [kuriaMessage75]);
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            });
 | 
					 | 
				
			||||||
                            if (progress >= 1.0) {
 | 
					                            if (progress >= 1.0) {
 | 
				
			||||||
                                void createMessage(inventory.accountOwnerId.toString(), [kuriaMessage100]);
 | 
					                                await createMessage(inventory.accountOwnerId.toString(), [kuriaMessage100]);
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
                        logger.warn(`${scan.CollectibleType} was not found in inventory, ignoring scans`);
 | 
					                        logger.warn(`${scan.CollectibleType} was not found in inventory, ignoring scans`);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case "Upgrades":
 | 
					            case "Upgrades":
 | 
				
			||||||
                value.forEach(clientUpgrade => {
 | 
					                value.forEach(clientUpgrade => {
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,11 @@
 | 
				
			|||||||
import { IEquipmentClient } from "./inventoryTypes/commonInventoryTypes";
 | 
					import { IEquipmentClient } from "./inventoryTypes/commonInventoryTypes";
 | 
				
			||||||
import { IDroneClient, IInfestedFoundryClient, IMiscItem, TEquipmentKey } from "./inventoryTypes/inventoryTypes";
 | 
					import {
 | 
				
			||||||
 | 
					    IDroneClient,
 | 
				
			||||||
 | 
					    IInfestedFoundryClient,
 | 
				
			||||||
 | 
					    IMiscItem,
 | 
				
			||||||
 | 
					    ITypeCount,
 | 
				
			||||||
 | 
					    TEquipmentKey
 | 
				
			||||||
 | 
					} from "./inventoryTypes/inventoryTypes";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IPurchaseRequest {
 | 
					export interface IPurchaseRequest {
 | 
				
			||||||
    PurchaseParams: IPurchaseParams;
 | 
					    PurchaseParams: IPurchaseParams;
 | 
				
			||||||
@ -33,6 +39,7 @@ export type IInventoryChanges = {
 | 
				
			|||||||
    InfestedFoundry?: IInfestedFoundryClient;
 | 
					    InfestedFoundry?: IInfestedFoundryClient;
 | 
				
			||||||
    Drones?: IDroneClient[];
 | 
					    Drones?: IDroneClient[];
 | 
				
			||||||
    MiscItems?: IMiscItem[];
 | 
					    MiscItems?: IMiscItem[];
 | 
				
			||||||
 | 
					    EmailItems?: ITypeCount[];
 | 
				
			||||||
} & Record<
 | 
					} & Record<
 | 
				
			||||||
        Exclude<
 | 
					        Exclude<
 | 
				
			||||||
            string,
 | 
					            string,
 | 
				
			||||||
@ -44,6 +51,7 @@ export type IInventoryChanges = {
 | 
				
			|||||||
            | "InfestedFoundry"
 | 
					            | "InfestedFoundry"
 | 
				
			||||||
            | "Drones"
 | 
					            | "Drones"
 | 
				
			||||||
            | "MiscItems"
 | 
					            | "MiscItems"
 | 
				
			||||||
 | 
					            | "EmailItems"
 | 
				
			||||||
        >,
 | 
					        >,
 | 
				
			||||||
        number | object[]
 | 
					        number | object[]
 | 
				
			||||||
    >;
 | 
					    >;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user