返回提交历史
Modified
src/controllers/api/inboxController.ts
+45
-68
Modified
src/models/loginModel.ts
+5
-1
Modified
src/services/configService.ts
+5
-0
Modified
src/types/loginTypes.ts
+4
-0
XFEstudio/XFESpaceNinjaServer
chore: keep track of which event messages were sent on account document (#3229)
Fixes #3226 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3229 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
3c7e9cea
代码差异
4 个文件
+59
-69
@@ -208,78 +208,55 @@ const createNewEventMessages = async (account: TAccountDocument): Promise<void>
208
208
});
209
209
}
210
210
211
// 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.
212
const promises = [];
213
if (config.worldState?.creditBoost) {
214
promises.push(
215
(async (): Promise<void> => {
216
if (!(await Inbox.exists({ ownerId: account._id, globaUpgradeId: "5b23106f283a555109666672" }))) {
217
newEventMessages.push({
218
globaUpgradeId: new Types.ObjectId("5b23106f283a555109666672"),
219
sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
220
sub: "/Lotus/Language/Items/EventDoubleCreditsName",
221
msg: "/Lotus/Language/Items/EventDoubleCreditsDesc",
222
icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png",
223
startDate: new Date(),
224
CrossPlatform: true
225
});
226
}
227
})()
228
);
211
if (config.worldState?.creditBoost && !account.receivedEventMessage_creditBoost) {
212
account.receivedEventMessage_creditBoost = true;
213
newEventMessages.push({
214
globaUpgradeId: new Types.ObjectId("5b23106f283a555109666672"),
215
sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
216
sub: "/Lotus/Language/Items/EventDoubleCreditsName",
217
msg: "/Lotus/Language/Items/EventDoubleCreditsDesc",
218
icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png",
219
startDate: new Date(),
220
CrossPlatform: true
221
});
229
222
}
230
if (config.worldState?.affinityBoost) {
231
promises.push(
232
(async (): Promise<void> => {
233
if (!(await Inbox.exists({ ownerId: account._id, globaUpgradeId: "5b23106f283a555109666673" }))) {
234
newEventMessages.push({
235
globaUpgradeId: new Types.ObjectId("5b23106f283a555109666673"),
236
sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
237
sub: "/Lotus/Language/Items/EventDoubleAffinityName",
238
msg: "/Lotus/Language/Items/EventDoubleAffinityDesc",
239
icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png",
240
startDate: new Date(),
241
CrossPlatform: true
242
});
243
}
244
})()
245
);
223
if (config.worldState?.affinityBoost && !account.receivedEventMessage_affinityBoost) {
224
account.receivedEventMessage_affinityBoost = true;
225
newEventMessages.push({
226
globaUpgradeId: new Types.ObjectId("5b23106f283a555109666673"),
227
sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
228
sub: "/Lotus/Language/Items/EventDoubleAffinityName",
229
msg: "/Lotus/Language/Items/EventDoubleAffinityDesc",
230
icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png",
231
startDate: new Date(),
232
CrossPlatform: true
233
});
246
234
}
247
if (config.worldState?.resourceBoost) {
248
promises.push(
249
(async (): Promise<void> => {
250
if (!(await Inbox.exists({ ownerId: account._id, globaUpgradeId: "5b23106f283a555109666674" }))) {
251
newEventMessages.push({
252
globaUpgradeId: new Types.ObjectId("5b23106f283a555109666674"),
253
sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
254
sub: "/Lotus/Language/Items/EventDoubleResourceName",
255
msg: "/Lotus/Language/Items/EventDoubleResourceDesc",
256
icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png",
257
startDate: new Date(),
258
CrossPlatform: true
259
});
260
}
261
})()
262
);
235
if (config.worldState?.resourceBoost && !account.receivedEventMessage_resourceBoost) {
236
account.receivedEventMessage_resourceBoost = true;
237
newEventMessages.push({
238
globaUpgradeId: new Types.ObjectId("5b23106f283a555109666674"),
239
sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
240
sub: "/Lotus/Language/Items/EventDoubleResourceName",
241
msg: "/Lotus/Language/Items/EventDoubleResourceDesc",
242
icon: "/Lotus/Interface/Icons/Npcs/Lotus_d.png",
243
startDate: new Date(),
244
CrossPlatform: true
245
});
263
246
}
264
if (config.worldState?.galleonOfGhouls) {
265
promises.push(
266
(async (): Promise<void> => {
267
if (!(await Inbox.exists({ ownerId: account._id, goalTag: "GalleonRobbery" }))) {
268
newEventMessages.push({
269
sndr: "/Lotus/Language/Bosses/BossCouncilorVayHek",
270
sub: "/Lotus/Language/Events/GalleonRobberyIntroMsgTitle",
271
msg: "/Lotus/Language/Events/GalleonRobberyIntroMsgDesc",
272
icon: "/Lotus/Interface/Icons/Npcs/VayHekPortrait.png",
273
transmission: "/Lotus/Sounds/Dialog/GalleonOfGhouls/DGhoulsWeekOneInbox0010VayHek",
274
att: ["/Lotus/Upgrades/Skins/Events/OgrisOldSchool"],
275
startDate: new Date(),
276
goalTag: "GalleonRobbery"
277
});
278
}
279
})()
280
);
247
if (config.worldState?.galleonOfGhouls && !account.receivedEventMessage_galleonOfGhouls) {
248
account.receivedEventMessage_galleonOfGhouls = true;
249
newEventMessages.push({
250
sndr: "/Lotus/Language/Bosses/BossCouncilorVayHek",
251
sub: "/Lotus/Language/Events/GalleonRobberyIntroMsgTitle",
252
msg: "/Lotus/Language/Events/GalleonRobberyIntroMsgDesc",
253
icon: "/Lotus/Interface/Icons/Npcs/VayHekPortrait.png",
254
transmission: "/Lotus/Sounds/Dialog/GalleonOfGhouls/DGhoulsWeekOneInbox0010VayHek",
255
att: ["/Lotus/Upgrades/Skins/Events/OgrisOldSchool"],
256
startDate: new Date(),
257
goalTag: "GalleonRobbery"
258
});
281
259
}
282
await Promise.all(promises);
283
260
284
261
if (newEventMessages.length === 0) {
285
262
return;
@@ -30,7 +30,11 @@ const databaseAccountSchema = new Schema<IDatabaseAccountJson>(
30
30
LatestEventMessageDate: { type: Date, default: 0 },
31
31
LastLoginRewardDate: { type: Number, default: 0 },
32
32
LoginDays: { type: Number, default: 1 },
33
DailyFirstWinDate: { type: Number, default: 0 }
33
DailyFirstWinDate: { type: Number, default: 0 },
34
receivedEventMessage_creditBoost: Boolean,
35
receivedEventMessage_affinityBoost: Boolean,
36
receivedEventMessage_resourceBoost: Boolean,
37
receivedEventMessage_galleonOfGhouls: Boolean
34
38
},
35
39
opts
36
40
);
@@ -4,6 +4,7 @@ import { repoDir } from "../helpers/pathHelper.ts";
4
4
import { args } from "../helpers/commandLineArguments.ts";
5
5
import { Inbox } from "../models/inboxModel.ts";
6
6
import type { Request } from "express";
7
import { Account } from "../models/loginModel.ts";
7
8
8
9
export interface IConfig {
9
10
mongodbUrl: string;
@@ -200,15 +201,19 @@ export const syncConfigWithDatabase = (): void => {
200
201
// 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.
201
202
// Also, for some reason, I can't just do `Inbox.deleteMany(...)`; - it needs this whole circus.
202
203
if (!config.worldState?.creditBoost) {
204
void Account.updateMany({}, { $unset: { receivedEventMessage_creditBoost: 1 } }).then(() => {});
203
205
void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666672" }).then(() => {});
204
206
}
205
207
if (!config.worldState?.affinityBoost) {
208
void Account.updateMany({}, { $unset: { receivedEventMessage_affinityBoost: 1 } }).then(() => {});
206
209
void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666673" }).then(() => {});
207
210
}
208
211
if (!config.worldState?.resourceBoost) {
212
void Account.updateMany({}, { $unset: { receivedEventMessage_resourceBoost: 1 } }).then(() => {});
209
213
void Inbox.deleteMany({ globaUpgradeId: "5b23106f283a555109666674" }).then(() => {});
210
214
}
211
215
if (!config.worldState?.galleonOfGhouls) {
216
void Account.updateMany({}, { $unset: { receivedEventMessage_galleonOfGhouls: 1 } }).then(() => {});
212
217
void Inbox.deleteMany({ goalTag: "GalleonRobbery" }).then(() => {});
213
218
}
214
219
};
@@ -27,6 +27,10 @@ export interface IDatabaseAccount extends IDatabaseAccountRequiredFields {
27
27
LastLoginRewardDate: number;
28
28
LoginDays: number;
29
29
DailyFirstWinDate: number;
30
receivedEventMessage_creditBoost?: boolean;
31
receivedEventMessage_affinityBoost?: boolean;
32
receivedEventMessage_resourceBoost?: boolean;
33
receivedEventMessage_galleonOfGhouls?: boolean;
30
34
}
31
35
32
36
// Includes virtual ID