XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

chore: accept ObjectId for accountId when sending inbox messages (#1409)

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1409 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

a0fa41cd
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

7 个文件 +17 -17
Modified src/controllers/api/contributeGuildClassController.ts +1 -1
@@ -41,7 +41,7 @@ export const contributeGuildClassController: RequestHandler = async (req, res) =
41 41 const members = await GuildMember.find({ guildId: payload.GuildId, status: 0 }, "accountId");
42 42 for (const member of members) {
43 43 // somewhat unfaithful as on live the "msg" is not a loctag, but since we don't have the string, we'll let the client fill it in with "arg".
44 await createMessage(member.accountId.toString(), [
44 await createMessage(member.accountId, [
45 45 {
46 46 sndr: guild.Name,
47 47 msg: "/Lotus/Language/Clan/Clan_AscensionCeremonyInProgressDetails",
Modified src/controllers/api/giftingController.ts +1 -1
@@ -56,7 +56,7 @@ export const giftingController: RequestHandler = async (req, res) => {
56 56 await senderInventory.save();
57 57
58 58 const senderName = getSuffixedName(senderAccount);
59 await createMessage(account._id.toString(), [
59 await createMessage(account._id, [
60 60 {
61 61 sndr: senderName,
62 62 msg: data.Message || "/Lotus/Language/Menu/GiftReceivedBody_NoCustomMessage",
Modified src/controllers/api/inboxController.ts +1 -1
@@ -67,7 +67,7 @@ export const inboxController: RequestHandler = async (req, res) => {
67 67 (await handleStoreItemAcquisition(gift.GiftType, inventory, giftQuantity)).InventoryChanges
68 68 );
69 69 if (sender) {
70 await createMessage(sender._id.toString(), [
70 await createMessage(sender._id, [
71 71 {
72 72 sndr: recipientName,
73 73 msg: "/Lotus/Language/Menu/GiftReceivedConfirmationBody",
Modified src/services/inboxService.ts +3 -3
@@ -1,6 +1,6 @@
1 1 import { IMessageDatabase, Inbox } from "@/src/models/inboxModel";
2 2 import { getAccountForRequest } from "@/src/services/loginService";
3 import { HydratedDocument } from "mongoose";
3 import { HydratedDocument, Types } from "mongoose";
4 4 import { Request } from "express";
5 5 import eventMessages from "@/static/fixed_responses/eventMessages.json";
6 6 import { logger } from "@/src/utils/logger";
@@ -39,7 +39,7 @@ export const createNewEventMessages = async (req: Request): Promise<void> => {
39 39 return;
40 40 }
41 41
42 const savedEventMessages = await createMessage(account._id.toString(), newEventMessages);
42 const savedEventMessages = await createMessage(account._id, newEventMessages);
43 43 logger.debug("created event messages", savedEventMessages);
44 44
45 45 const latestEventMessage = newEventMessages.reduce((prev, current) =>
@@ -50,7 +50,7 @@ export const createNewEventMessages = async (req: Request): Promise<void> => {
50 50 await account.save();
51 51 };
52 52
53 export const createMessage = async (accountId: string, messages: IMessageCreationTemplate[]) => {
53 export const createMessage = async (accountId: string | Types.ObjectId, messages: IMessageCreationTemplate[]) => {
54 54 const ownerIdMessages = messages.map(m => ({
55 55 ...m,
56 56 ownerId: accountId
Modified src/services/inventoryService.ts +1 -1
@@ -1019,7 +1019,7 @@ export const addEmailItem = async (
1019 1019 const meta = ExportEmailItems[typeName];
1020 1020 const emailItem = inventory.EmailItems.find(x => x.ItemType == typeName);
1021 1021 if (!emailItem || !meta.sendOnlyOnce) {
1022 await createMessage(inventory.accountOwnerId.toString(), [convertInboxMessage(meta.message)]);
1022 await createMessage(inventory.accountOwnerId, [convertInboxMessage(meta.message)]);
1023 1023
1024 1024 if (emailItem) {
1025 1025 emailItem.ItemCount += 1;
Modified src/services/missionInventoryUpdateService.ts +6 -6
@@ -105,13 +105,13 @@ export const addMissionInventoryUpdates = async (
105 105 if (!inventory.BrandedSuits.find(x => x.equals(SuitId))) {
106 106 inventory.BrandedSuits.push(SuitId);
107 107
108 await createMessage(inventory.accountOwnerId.toString(), [
108 await createMessage(inventory.accountOwnerId, [
109 109 {
110 110 sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
111 111 msg: "/Lotus/Language/G1Quests/BrandedMessage",
112 112 sub: "/Lotus/Language/G1Quests/BrandedTitle",
113 113 att: ["/Lotus/Types/Recipes/Components/BrandRemovalBlueprint"],
114 highPriority: true // I cannot find any content of this within the last 10 years so I can only assume that highPriority is set (it certainly would make sense), but I just don't know for sure that it is so on live.
114 highPriority: true // TOVERIFY: I cannot find any content of this within the last 10 years so I can only assume that highPriority is set (it certainly would make sense), but I just don't know for sure that it is so on live.
115 115 }
116 116 ]);
117 117 }
@@ -292,14 +292,14 @@ export const addMissionInventoryUpdates = async (
292 292 if (gate.complete && !gate.sent) {
293 293 gate.sent = true;
294 294 if (gate.threshold == 0.5) {
295 await createMessage(inventory.accountOwnerId.toString(), [kuriaMessage50]);
295 await createMessage(inventory.accountOwnerId, [kuriaMessage50]);
296 296 } else {
297 await createMessage(inventory.accountOwnerId.toString(), [kuriaMessage75]);
297 await createMessage(inventory.accountOwnerId, [kuriaMessage75]);
298 298 }
299 299 }
300 300 }
301 301 if (progress >= 1.0) {
302 await createMessage(inventory.accountOwnerId.toString(), [kuriaMessage100]);
302 await createMessage(inventory.accountOwnerId, [kuriaMessage100]);
303 303 }
304 304 }
305 305 } else {
@@ -338,7 +338,7 @@ export const addMissionInventoryUpdates = async (
338 338 for (const deathMark of value) {
339 339 if (!inventory.DeathMarks.find(x => x == deathMark)) {
340 340 // It's a new death mark; we have to say the line.
341 await createMessage(inventory.accountOwnerId.toString(), [
341 await createMessage(inventory.accountOwnerId, [
342 342 {
343 343 sub: "/Lotus/Language/G1Quests/DeathMarkTitle",
344 344 sndr: "/Lotus/Language/G1Quests/DeathMarkSender",
Modified src/services/questService.ts +4 -4
@@ -16,7 +16,7 @@ import {
16 16 IQuestStage
17 17 } from "@/src/types/inventoryTypes/inventoryTypes";
18 18 import { logger } from "@/src/utils/logger";
19 import { HydratedDocument } from "mongoose";
19 import { HydratedDocument, Types } from "mongoose";
20 20 import { ExportKeys } from "warframe-public-export-plus";
21 21 import { addFixedLevelRewards } from "./missionInventoryUpdateService";
22 22 import { IInventoryChanges } from "../types/purchaseTypes";
@@ -107,7 +107,7 @@ export const addQuestKey = (
107 107 }
108 108
109 109 if (questKey.ItemType == "/Lotus/Types/Keys/InfestedMicroplanetQuest/InfestedMicroplanetQuestKeyChain") {
110 void createMessage(inventory.accountOwnerId.toString(), [
110 void createMessage(inventory.accountOwnerId, [
111 111 {
112 112 sndr: "/Lotus/Language/Bosses/Loid",
113 113 icon: "/Lotus/Interface/Icons/Npcs/Entrati/Loid.png",
@@ -166,7 +166,7 @@ export const completeQuest = async (inventory: TInventoryDatabaseDocument, quest
166 166 }
167 167
168 168 if (chainStages[i].messageToSendWhenTriggered) {
169 await giveKeyChainMessage(inventory, inventory.accountOwnerId.toString(), {
169 await giveKeyChainMessage(inventory, inventory.accountOwnerId, {
170 170 KeyChain: questKey,
171 171 ChainStage: i
172 172 });
@@ -238,7 +238,7 @@ export const giveKeyChainItem = async (
238 238
239 239 export const giveKeyChainMessage = async (
240 240 inventory: TInventoryDatabaseDocument,
241 accountId: string,
241 accountId: string | Types.ObjectId,
242 242 keyChainInfo: IKeyChainRequest
243 243 ): Promise<void> => {
244 244 const keyChainMessage = getKeyChainMessage(keyChainInfo);