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";
|
||||
|
||||
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;
|
||||
globaUpgradeId?: IOid; // [sic]
|
||||
date: IMongoDate;
|
||||
startDate?: IMongoDate;
|
||||
endDate?: IMongoDate;
|
||||
@ -14,6 +18,7 @@ export interface IMessageClient
|
||||
|
||||
export interface IMessageDatabase extends IMessage {
|
||||
ownerId: Types.ObjectId;
|
||||
globaUpgradeId?: Types.ObjectId; // [sic]
|
||||
date: Date; //created at
|
||||
attVisualOnly?: boolean;
|
||||
_id: Types.ObjectId;
|
||||
@ -101,6 +106,7 @@ const giftSchema = new Schema<IGift>(
|
||||
const messageSchema = new Schema<IMessageDatabase>(
|
||||
{
|
||||
ownerId: Schema.Types.ObjectId,
|
||||
globaUpgradeId: Schema.Types.ObjectId,
|
||||
sndr: String,
|
||||
msg: String,
|
||||
cinematic: String,
|
||||
@ -154,6 +160,10 @@ messageSchema.set("toJSON", {
|
||||
delete returnedObject.attVisualOnly;
|
||||
delete returnedObject.expiry;
|
||||
|
||||
if (messageDatabase.globaUpgradeId) {
|
||||
messageClient.globaUpgradeId = toOid(messageDatabase.globaUpgradeId);
|
||||
}
|
||||
|
||||
messageClient.date = toMongoDate(messageDatabase.date);
|
||||
|
||||
if (messageDatabase.startDate && messageDatabase.endDate) {
|
||||
|
@ -71,7 +71,17 @@ export const validateConfig = (): 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.
|
||||
// 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) {
|
||||
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,7 +55,61 @@ 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.
|
||||
const promises = [];
|
||||
if (config.worldState?.creditBoost) {
|
||||
promises.push(
|
||||
(async (): Promise<void> => {
|
||||
if (!(await Inbox.exists({ ownerId: account._id, globaUpgradeId: "5b23106f283a555109666672" }))) {
|
||||
newEventMessages.push({
|
||||
globaUpgradeId: new Types.ObjectId("5b23106f283a555109666672"),
|
||||
sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
|
||||
sub: "/Lotus/Language/Items/EventDoubleCreditsName",
|
||||
msg: "/Lotus/Language/Items/EventDoubleCreditsDesc",
|
||||
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",
|
||||
@ -68,7 +122,10 @@ export const createNewEventMessages = async (req: Request): Promise<void> => {
|
||||
goalTag: "GalleonRobbery"
|
||||
});
|
||||
}
|
||||
})()
|
||||
);
|
||||
}
|
||||
await Promise.all(promises);
|
||||
|
||||
if (newEventMessages.length === 0) {
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user