forked from OpenWF/SpaceNinjaServer
		
	chore: send event messages for boosters (#2487)
Closes #2464 Reviewed-on: OpenWF/SpaceNinjaServer#2487 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									db86e2d265
								
							
						
					
					
						commit
						b3bf291d10
					
				@ -4,8 +4,12 @@ import { typeCountSchema } from "@/src/models/inventoryModels/inventoryModel";
 | 
				
			|||||||
import { IMongoDate, IOid, ITypeCount } from "@/src/types/commonTypes";
 | 
					import { IMongoDate, IOid, ITypeCount } from "@/src/types/commonTypes";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface IMessageClient
 | 
					export interface IMessageClient
 | 
				
			||||||
    extends Omit<IMessageDatabase, "_id" | "date" | "startDate" | "endDate" | "ownerId" | "attVisualOnly" | "expiry"> {
 | 
					    extends Omit<
 | 
				
			||||||
 | 
					        IMessageDatabase,
 | 
				
			||||||
 | 
					        "_id" | "globaUpgradeId" | "date" | "startDate" | "endDate" | "ownerId" | "attVisualOnly" | "expiry"
 | 
				
			||||||
 | 
					    > {
 | 
				
			||||||
    _id?: IOid;
 | 
					    _id?: IOid;
 | 
				
			||||||
 | 
					    globaUpgradeId?: IOid; // [sic]
 | 
				
			||||||
    date: IMongoDate;
 | 
					    date: IMongoDate;
 | 
				
			||||||
    startDate?: IMongoDate;
 | 
					    startDate?: IMongoDate;
 | 
				
			||||||
    endDate?: IMongoDate;
 | 
					    endDate?: IMongoDate;
 | 
				
			||||||
@ -14,6 +18,7 @@ export interface IMessageClient
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export interface IMessageDatabase extends IMessage {
 | 
					export interface IMessageDatabase extends IMessage {
 | 
				
			||||||
    ownerId: Types.ObjectId;
 | 
					    ownerId: Types.ObjectId;
 | 
				
			||||||
 | 
					    globaUpgradeId?: Types.ObjectId; // [sic]
 | 
				
			||||||
    date: Date; //created at
 | 
					    date: Date; //created at
 | 
				
			||||||
    attVisualOnly?: boolean;
 | 
					    attVisualOnly?: boolean;
 | 
				
			||||||
    _id: Types.ObjectId;
 | 
					    _id: Types.ObjectId;
 | 
				
			||||||
@ -101,6 +106,7 @@ const giftSchema = new Schema<IGift>(
 | 
				
			|||||||
const messageSchema = new Schema<IMessageDatabase>(
 | 
					const messageSchema = new Schema<IMessageDatabase>(
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        ownerId: Schema.Types.ObjectId,
 | 
					        ownerId: Schema.Types.ObjectId,
 | 
				
			||||||
 | 
					        globaUpgradeId: Schema.Types.ObjectId,
 | 
				
			||||||
        sndr: String,
 | 
					        sndr: String,
 | 
				
			||||||
        msg: String,
 | 
					        msg: String,
 | 
				
			||||||
        cinematic: String,
 | 
					        cinematic: String,
 | 
				
			||||||
@ -154,6 +160,10 @@ messageSchema.set("toJSON", {
 | 
				
			|||||||
        delete returnedObject.attVisualOnly;
 | 
					        delete returnedObject.attVisualOnly;
 | 
				
			||||||
        delete returnedObject.expiry;
 | 
					        delete returnedObject.expiry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (messageDatabase.globaUpgradeId) {
 | 
				
			||||||
 | 
					            messageClient.globaUpgradeId = toOid(messageDatabase.globaUpgradeId);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        messageClient.date = toMongoDate(messageDatabase.date);
 | 
					        messageClient.date = toMongoDate(messageDatabase.date);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (messageDatabase.startDate && messageDatabase.endDate) {
 | 
					        if (messageDatabase.startDate && messageDatabase.endDate) {
 | 
				
			||||||
 | 
				
			|||||||
@ -71,7 +71,17 @@ export const validateConfig = (): void => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export const syncConfigWithDatabase = (): void => {
 | 
					export const syncConfigWithDatabase = (): void => {
 | 
				
			||||||
    // Event messages are deleted after endDate. Since we don't use beginDate/endDate and instead have config toggles, we need to delete the messages once those bools are false.
 | 
					    // Event messages are deleted after endDate. Since we don't use beginDate/endDate and instead have config toggles, we need to delete the messages once those bools are false.
 | 
				
			||||||
 | 
					    // Also, for some reason, I can't just do `Inbox.deleteMany(...)`; - it needs this whole circus.
 | 
				
			||||||
 | 
					    if (!config.worldState?.creditBoost) {
 | 
				
			||||||
 | 
					        void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666672" }).then(() => {});
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (!config.worldState?.affinityBoost) {
 | 
				
			||||||
 | 
					        void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666673" }).then(() => {});
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (!config.worldState?.resourceBoost) {
 | 
				
			||||||
 | 
					        void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666674" }).then(() => {});
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (!config.worldState?.galleonOfGhouls) {
 | 
					    if (!config.worldState?.galleonOfGhouls) {
 | 
				
			||||||
        void Inbox.deleteMany({ goalTag: "GalleonRobbery" }).then(() => {}); // For some reason, I can't just do `Inbox.deleteMany(...)`; it needs this whole circus.
 | 
					        void Inbox.deleteMany({ goalTag: "GalleonRobbery" }).then(() => {});
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -55,20 +55,77 @@ export const createNewEventMessages = async (req: Request): Promise<void> => {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // BUG: Deleting the inbox message manually means it'll just be automatically re-created. This is because we don't use startDate/endDate for these config-toggled events.
 | 
					    // BUG: Deleting the inbox message manually means it'll just be automatically re-created. This is because we don't use startDate/endDate for these config-toggled events.
 | 
				
			||||||
    if (config.worldState?.galleonOfGhouls) {
 | 
					    const promises = [];
 | 
				
			||||||
        if (!(await Inbox.exists({ ownerId: account._id, goalTag: "GalleonRobbery" }))) {
 | 
					    if (config.worldState?.creditBoost) {
 | 
				
			||||||
            newEventMessages.push({
 | 
					        promises.push(
 | 
				
			||||||
                sndr: "/Lotus/Language/Bosses/BossCouncilorVayHek",
 | 
					            (async (): Promise<void> => {
 | 
				
			||||||
                sub: "/Lotus/Language/Events/GalleonRobberyIntroMsgTitle",
 | 
					                if (!(await Inbox.exists({ ownerId: account._id, globaUpgradeId: "5b23106f283a555109666672" }))) {
 | 
				
			||||||
                msg: "/Lotus/Language/Events/GalleonRobberyIntroMsgDesc",
 | 
					                    newEventMessages.push({
 | 
				
			||||||
                icon: "/Lotus/Interface/Icons/Npcs/VayHekPortrait.png",
 | 
					                        globaUpgradeId: new Types.ObjectId("5b23106f283a555109666672"),
 | 
				
			||||||
                transmission: "/Lotus/Sounds/Dialog/GalleonOfGhouls/DGhoulsWeekOneInbox0010VayHek",
 | 
					                        sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
 | 
				
			||||||
                att: ["/Lotus/Upgrades/Skins/Events/OgrisOldSchool"],
 | 
					                        sub: "/Lotus/Language/Items/EventDoubleCreditsName",
 | 
				
			||||||
                startDate: new Date(),
 | 
					                        msg: "/Lotus/Language/Items/EventDoubleCreditsDesc",
 | 
				
			||||||
                goalTag: "GalleonRobbery"
 | 
					                        icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png",
 | 
				
			||||||
            });
 | 
					                        startDate: new Date(),
 | 
				
			||||||
        }
 | 
					                        CrossPlatform: true
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            })()
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    if (config.worldState?.affinityBoost) {
 | 
				
			||||||
 | 
					        promises.push(
 | 
				
			||||||
 | 
					            (async (): Promise<void> => {
 | 
				
			||||||
 | 
					                if (!(await Inbox.exists({ ownerId: account._id, globaUpgradeId: "5b23106f283a555109666673" }))) {
 | 
				
			||||||
 | 
					                    newEventMessages.push({
 | 
				
			||||||
 | 
					                        globaUpgradeId: new Types.ObjectId("5b23106f283a555109666673"),
 | 
				
			||||||
 | 
					                        sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
 | 
				
			||||||
 | 
					                        sub: "/Lotus/Language/Items/EventDoubleAffinityName",
 | 
				
			||||||
 | 
					                        msg: "/Lotus/Language/Items/EventDoubleAffinityDesc",
 | 
				
			||||||
 | 
					                        icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png",
 | 
				
			||||||
 | 
					                        startDate: new Date(),
 | 
				
			||||||
 | 
					                        CrossPlatform: true
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            })()
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (config.worldState?.resourceBoost) {
 | 
				
			||||||
 | 
					        promises.push(
 | 
				
			||||||
 | 
					            (async (): Promise<void> => {
 | 
				
			||||||
 | 
					                if (!(await Inbox.exists({ ownerId: account._id, globaUpgradeId: "5b23106f283a555109666674" }))) {
 | 
				
			||||||
 | 
					                    newEventMessages.push({
 | 
				
			||||||
 | 
					                        globaUpgradeId: new Types.ObjectId("5b23106f283a555109666674"),
 | 
				
			||||||
 | 
					                        sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
 | 
				
			||||||
 | 
					                        sub: "/Lotus/Language/Items/EventDoubleResourceName",
 | 
				
			||||||
 | 
					                        msg: "/Lotus/Language/Items/EventDoubleResourceDesc",
 | 
				
			||||||
 | 
					                        icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png",
 | 
				
			||||||
 | 
					                        startDate: new Date(),
 | 
				
			||||||
 | 
					                        CrossPlatform: true
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            })()
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (config.worldState?.galleonOfGhouls) {
 | 
				
			||||||
 | 
					        promises.push(
 | 
				
			||||||
 | 
					            (async (): Promise<void> => {
 | 
				
			||||||
 | 
					                if (!(await Inbox.exists({ ownerId: account._id, goalTag: "GalleonRobbery" }))) {
 | 
				
			||||||
 | 
					                    newEventMessages.push({
 | 
				
			||||||
 | 
					                        sndr: "/Lotus/Language/Bosses/BossCouncilorVayHek",
 | 
				
			||||||
 | 
					                        sub: "/Lotus/Language/Events/GalleonRobberyIntroMsgTitle",
 | 
				
			||||||
 | 
					                        msg: "/Lotus/Language/Events/GalleonRobberyIntroMsgDesc",
 | 
				
			||||||
 | 
					                        icon: "/Lotus/Interface/Icons/Npcs/VayHekPortrait.png",
 | 
				
			||||||
 | 
					                        transmission: "/Lotus/Sounds/Dialog/GalleonOfGhouls/DGhoulsWeekOneInbox0010VayHek",
 | 
				
			||||||
 | 
					                        att: ["/Lotus/Upgrades/Skins/Events/OgrisOldSchool"],
 | 
				
			||||||
 | 
					                        startDate: new Date(),
 | 
				
			||||||
 | 
					                        goalTag: "GalleonRobbery"
 | 
				
			||||||
 | 
					                    });
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            })()
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    await Promise.all(promises);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (newEventMessages.length === 0) {
 | 
					    if (newEventMessages.length === 0) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user