返回提交历史
Modified
src/models/inboxModel.ts
+11
-1
Modified
src/services/configWatcherService.ts
+11
-1
Modified
src/services/inboxService.ts
+69
-12
XFEstudio/XFESpaceNinjaServer
chore: send event messages for boosters (#2487)
Closes #2464 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2487 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
b3bf291d
代码差异
3 个文件
+91
-14
@@ -4,8 +4,12 @@ import { typeCountSchema } from "@/src/models/inventoryModels/inventoryModel";
4
4
import { IMongoDate, IOid, ITypeCount } from "@/src/types/commonTypes";
5
5
6
6
export interface IMessageClient
7
extends Omit<IMessageDatabase, "_id" | "date" | "startDate" | "endDate" | "ownerId" | "attVisualOnly" | "expiry"> {
7
extends Omit<
8
IMessageDatabase,
9
"_id" | "globaUpgradeId" | "date" | "startDate" | "endDate" | "ownerId" | "attVisualOnly" | "expiry"
10
> {
8
11
_id?: IOid;
12
globaUpgradeId?: IOid; // [sic]
9
13
date: IMongoDate;
10
14
startDate?: IMongoDate;
11
15
endDate?: IMongoDate;
@@ -14,6 +18,7 @@ export interface IMessageClient
14
18
15
19
export interface IMessageDatabase extends IMessage {
16
20
ownerId: Types.ObjectId;
21
globaUpgradeId?: Types.ObjectId; // [sic]
17
22
date: Date; //created at
18
23
attVisualOnly?: boolean;
19
24
_id: Types.ObjectId;
@@ -101,6 +106,7 @@ const giftSchema = new Schema<IGift>(
101
106
const messageSchema = new Schema<IMessageDatabase>(
102
107
{
103
108
ownerId: Schema.Types.ObjectId,
109
globaUpgradeId: Schema.Types.ObjectId,
104
110
sndr: String,
105
111
msg: String,
106
112
cinematic: String,
@@ -154,6 +160,10 @@ messageSchema.set("toJSON", {
154
160
delete returnedObject.attVisualOnly;
155
161
delete returnedObject.expiry;
156
162
163
if (messageDatabase.globaUpgradeId) {
164
messageClient.globaUpgradeId = toOid(messageDatabase.globaUpgradeId);
165
}
166
157
167
messageClient.date = toMongoDate(messageDatabase.date);
158
168
159
169
if (messageDatabase.startDate && messageDatabase.endDate) {
@@ -71,7 +71,17 @@ export const validateConfig = (): void => {
71
71
72
72
export const syncConfigWithDatabase = (): void => {
73
73
// 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.
74
// Also, for some reason, I can't just do `Inbox.deleteMany(...)`; - it needs this whole circus.
75
if (!config.worldState?.creditBoost) {
76
void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666672" }).then(() => {});
77
}
78
if (!config.worldState?.affinityBoost) {
79
void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666673" }).then(() => {});
80
}
81
if (!config.worldState?.resourceBoost) {
82
void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666674" }).then(() => {});
83
}
74
84
if (!config.worldState?.galleonOfGhouls) {
75
void Inbox.deleteMany({ goalTag: "GalleonRobbery" }).then(() => {}); // For some reason, I can't just do `Inbox.deleteMany(...)`; it needs this whole circus.
85
void Inbox.deleteMany({ goalTag: "GalleonRobbery" }).then(() => {});
76
86
}
77
87
};
@@ -55,20 +55,77 @@ export const createNewEventMessages = async (req: Request): Promise<void> => {
55
55
}
56
56
57
57
// 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.
58
const promises = [];
59
if (config.worldState?.creditBoost) {
60
promises.push(
61
(async (): Promise<void> => {
62
if (!(await Inbox.exists({ ownerId: account._id, globaUpgradeId: "5b23106f283a555109666672" }))) {
63
newEventMessages.push({
64
globaUpgradeId: new Types.ObjectId("5b23106f283a555109666672"),
65
sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
66
sub: "/Lotus/Language/Items/EventDoubleCreditsName",
67
msg: "/Lotus/Language/Items/EventDoubleCreditsDesc",
68
icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png",
69
startDate: new Date(),
70
CrossPlatform: true
71
});
72
}
73
})()
74
);
75
}
76
if (config.worldState?.affinityBoost) {
77
promises.push(
78
(async (): Promise<void> => {
79
if (!(await Inbox.exists({ ownerId: account._id, globaUpgradeId: "5b23106f283a555109666673" }))) {
80
newEventMessages.push({
81
globaUpgradeId: new Types.ObjectId("5b23106f283a555109666673"),
82
sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
83
sub: "/Lotus/Language/Items/EventDoubleAffinityName",
84
msg: "/Lotus/Language/Items/EventDoubleAffinityDesc",
85
icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png",
86
startDate: new Date(),
87
CrossPlatform: true
88
});
89
}
90
})()
91
);
92
}
93
if (config.worldState?.resourceBoost) {
94
promises.push(
95
(async (): Promise<void> => {
96
if (!(await Inbox.exists({ ownerId: account._id, globaUpgradeId: "5b23106f283a555109666674" }))) {
97
newEventMessages.push({
98
globaUpgradeId: new Types.ObjectId("5b23106f283a555109666674"),
99
sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
100
sub: "/Lotus/Language/Items/EventDoubleResourceName",
101
msg: "/Lotus/Language/Items/EventDoubleResourceDesc",
102
icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png",
103
startDate: new Date(),
104
CrossPlatform: true
105
});
106
}
107
})()
108
);
109
}
58
110
if (config.worldState?.galleonOfGhouls) {
59
if (!(await Inbox.exists({ ownerId: account._id, goalTag: "GalleonRobbery" }))) {
60
newEventMessages.push({
61
sndr: "/Lotus/Language/Bosses/BossCouncilorVayHek",
62
sub: "/Lotus/Language/Events/GalleonRobberyIntroMsgTitle",
63
msg: "/Lotus/Language/Events/GalleonRobberyIntroMsgDesc",
64
icon: "/Lotus/Interface/Icons/Npcs/VayHekPortrait.png",
65
transmission: "/Lotus/Sounds/Dialog/GalleonOfGhouls/DGhoulsWeekOneInbox0010VayHek",
66
att: ["/Lotus/Upgrades/Skins/Events/OgrisOldSchool"],
67
startDate: new Date(),
68
goalTag: "GalleonRobbery"
69
});
70
}
111
promises.push(
112
(async (): Promise<void> => {
113
if (!(await Inbox.exists({ ownerId: account._id, goalTag: "GalleonRobbery" }))) {
114
newEventMessages.push({
115
sndr: "/Lotus/Language/Bosses/BossCouncilorVayHek",
116
sub: "/Lotus/Language/Events/GalleonRobberyIntroMsgTitle",
117
msg: "/Lotus/Language/Events/GalleonRobberyIntroMsgDesc",
118
icon: "/Lotus/Interface/Icons/Npcs/VayHekPortrait.png",
119
transmission: "/Lotus/Sounds/Dialog/GalleonOfGhouls/DGhoulsWeekOneInbox0010VayHek",
120
att: ["/Lotus/Upgrades/Skins/Events/OgrisOldSchool"],
121
startDate: new Date(),
122
goalTag: "GalleonRobbery"
123
});
124
}
125
})()
126
);
71
127
}
128
await Promise.all(promises);
72
129
73
130
if (newEventMessages.length === 0) {
74
131
return;