forked from OpenWF/SpaceNinjaServer
		
	chore: accept ObjectId for accountId when sending inbox messages (#1409)
Reviewed-on: OpenWF/SpaceNinjaServer#1409 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
							
								
									9162522962
								
							
						
					
					
						commit
						a0fa41cd58
					
				@ -41,7 +41,7 @@ export const contributeGuildClassController: RequestHandler = async (req, res) =
 | 
				
			|||||||
            const members = await GuildMember.find({ guildId: payload.GuildId, status: 0 }, "accountId");
 | 
					            const members = await GuildMember.find({ guildId: payload.GuildId, status: 0 }, "accountId");
 | 
				
			||||||
            for (const member of members) {
 | 
					            for (const member of members) {
 | 
				
			||||||
                // 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".
 | 
					                // 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".
 | 
				
			||||||
                await createMessage(member.accountId.toString(), [
 | 
					                await createMessage(member.accountId, [
 | 
				
			||||||
                    {
 | 
					                    {
 | 
				
			||||||
                        sndr: guild.Name,
 | 
					                        sndr: guild.Name,
 | 
				
			||||||
                        msg: "/Lotus/Language/Clan/Clan_AscensionCeremonyInProgressDetails",
 | 
					                        msg: "/Lotus/Language/Clan/Clan_AscensionCeremonyInProgressDetails",
 | 
				
			||||||
 | 
				
			|||||||
@ -56,7 +56,7 @@ export const giftingController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
    await senderInventory.save();
 | 
					    await senderInventory.save();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const senderName = getSuffixedName(senderAccount);
 | 
					    const senderName = getSuffixedName(senderAccount);
 | 
				
			||||||
    await createMessage(account._id.toString(), [
 | 
					    await createMessage(account._id, [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            sndr: senderName,
 | 
					            sndr: senderName,
 | 
				
			||||||
            msg: data.Message || "/Lotus/Language/Menu/GiftReceivedBody_NoCustomMessage",
 | 
					            msg: data.Message || "/Lotus/Language/Menu/GiftReceivedBody_NoCustomMessage",
 | 
				
			||||||
 | 
				
			|||||||
@ -67,7 +67,7 @@ export const inboxController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
                    (await handleStoreItemAcquisition(gift.GiftType, inventory, giftQuantity)).InventoryChanges
 | 
					                    (await handleStoreItemAcquisition(gift.GiftType, inventory, giftQuantity)).InventoryChanges
 | 
				
			||||||
                );
 | 
					                );
 | 
				
			||||||
                if (sender) {
 | 
					                if (sender) {
 | 
				
			||||||
                    await createMessage(sender._id.toString(), [
 | 
					                    await createMessage(sender._id, [
 | 
				
			||||||
                        {
 | 
					                        {
 | 
				
			||||||
                            sndr: recipientName,
 | 
					                            sndr: recipientName,
 | 
				
			||||||
                            msg: "/Lotus/Language/Menu/GiftReceivedConfirmationBody",
 | 
					                            msg: "/Lotus/Language/Menu/GiftReceivedConfirmationBody",
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
import { IMessageDatabase, Inbox } from "@/src/models/inboxModel";
 | 
					import { IMessageDatabase, Inbox } from "@/src/models/inboxModel";
 | 
				
			||||||
import { getAccountForRequest } from "@/src/services/loginService";
 | 
					import { getAccountForRequest } from "@/src/services/loginService";
 | 
				
			||||||
import { HydratedDocument } from "mongoose";
 | 
					import { HydratedDocument, Types } from "mongoose";
 | 
				
			||||||
import { Request } from "express";
 | 
					import { Request } from "express";
 | 
				
			||||||
import eventMessages from "@/static/fixed_responses/eventMessages.json";
 | 
					import eventMessages from "@/static/fixed_responses/eventMessages.json";
 | 
				
			||||||
import { logger } from "@/src/utils/logger";
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
@ -39,7 +39,7 @@ export const createNewEventMessages = async (req: Request): Promise<void> => {
 | 
				
			|||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const savedEventMessages = await createMessage(account._id.toString(), newEventMessages);
 | 
					    const savedEventMessages = await createMessage(account._id, newEventMessages);
 | 
				
			||||||
    logger.debug("created event messages", savedEventMessages);
 | 
					    logger.debug("created event messages", savedEventMessages);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const latestEventMessage = newEventMessages.reduce((prev, current) =>
 | 
					    const latestEventMessage = newEventMessages.reduce((prev, current) =>
 | 
				
			||||||
@ -50,7 +50,7 @@ export const createNewEventMessages = async (req: Request): Promise<void> => {
 | 
				
			|||||||
    await account.save();
 | 
					    await account.save();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const createMessage = async (accountId: string, messages: IMessageCreationTemplate[]) => {
 | 
					export const createMessage = async (accountId: string | Types.ObjectId, messages: IMessageCreationTemplate[]) => {
 | 
				
			||||||
    const ownerIdMessages = messages.map(m => ({
 | 
					    const ownerIdMessages = messages.map(m => ({
 | 
				
			||||||
        ...m,
 | 
					        ...m,
 | 
				
			||||||
        ownerId: accountId
 | 
					        ownerId: accountId
 | 
				
			||||||
 | 
				
			|||||||
@ -1019,7 +1019,7 @@ export const addEmailItem = async (
 | 
				
			|||||||
    const meta = ExportEmailItems[typeName];
 | 
					    const meta = ExportEmailItems[typeName];
 | 
				
			||||||
    const emailItem = inventory.EmailItems.find(x => x.ItemType == typeName);
 | 
					    const emailItem = inventory.EmailItems.find(x => x.ItemType == typeName);
 | 
				
			||||||
    if (!emailItem || !meta.sendOnlyOnce) {
 | 
					    if (!emailItem || !meta.sendOnlyOnce) {
 | 
				
			||||||
        await createMessage(inventory.accountOwnerId.toString(), [convertInboxMessage(meta.message)]);
 | 
					        await createMessage(inventory.accountOwnerId, [convertInboxMessage(meta.message)]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (emailItem) {
 | 
					        if (emailItem) {
 | 
				
			||||||
            emailItem.ItemCount += 1;
 | 
					            emailItem.ItemCount += 1;
 | 
				
			||||||
 | 
				
			|||||||
@ -105,13 +105,13 @@ export const addMissionInventoryUpdates = async (
 | 
				
			|||||||
        if (!inventory.BrandedSuits.find(x => x.equals(SuitId))) {
 | 
					        if (!inventory.BrandedSuits.find(x => x.equals(SuitId))) {
 | 
				
			||||||
            inventory.BrandedSuits.push(SuitId);
 | 
					            inventory.BrandedSuits.push(SuitId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            await createMessage(inventory.accountOwnerId.toString(), [
 | 
					            await createMessage(inventory.accountOwnerId, [
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
 | 
					                    sndr: "/Lotus/Language/Menu/Mailbox_WarframeSender",
 | 
				
			||||||
                    msg: "/Lotus/Language/G1Quests/BrandedMessage",
 | 
					                    msg: "/Lotus/Language/G1Quests/BrandedMessage",
 | 
				
			||||||
                    sub: "/Lotus/Language/G1Quests/BrandedTitle",
 | 
					                    sub: "/Lotus/Language/G1Quests/BrandedTitle",
 | 
				
			||||||
                    att: ["/Lotus/Types/Recipes/Components/BrandRemovalBlueprint"],
 | 
					                    att: ["/Lotus/Types/Recipes/Components/BrandRemovalBlueprint"],
 | 
				
			||||||
                    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.
 | 
					                    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.
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            ]);
 | 
					            ]);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -292,14 +292,14 @@ export const addMissionInventoryUpdates = async (
 | 
				
			|||||||
                                if (gate.complete && !gate.sent) {
 | 
					                                if (gate.complete && !gate.sent) {
 | 
				
			||||||
                                    gate.sent = true;
 | 
					                                    gate.sent = true;
 | 
				
			||||||
                                    if (gate.threshold == 0.5) {
 | 
					                                    if (gate.threshold == 0.5) {
 | 
				
			||||||
                                        await createMessage(inventory.accountOwnerId.toString(), [kuriaMessage50]);
 | 
					                                        await createMessage(inventory.accountOwnerId, [kuriaMessage50]);
 | 
				
			||||||
                                    } else {
 | 
					                                    } else {
 | 
				
			||||||
                                        await createMessage(inventory.accountOwnerId.toString(), [kuriaMessage75]);
 | 
					                                        await createMessage(inventory.accountOwnerId, [kuriaMessage75]);
 | 
				
			||||||
                                    }
 | 
					                                    }
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            if (progress >= 1.0) {
 | 
					                            if (progress >= 1.0) {
 | 
				
			||||||
                                await createMessage(inventory.accountOwnerId.toString(), [kuriaMessage100]);
 | 
					                                await createMessage(inventory.accountOwnerId, [kuriaMessage100]);
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    } else {
 | 
					                    } else {
 | 
				
			||||||
@ -338,7 +338,7 @@ export const addMissionInventoryUpdates = async (
 | 
				
			|||||||
                for (const deathMark of value) {
 | 
					                for (const deathMark of value) {
 | 
				
			||||||
                    if (!inventory.DeathMarks.find(x => x == deathMark)) {
 | 
					                    if (!inventory.DeathMarks.find(x => x == deathMark)) {
 | 
				
			||||||
                        // It's a new death mark; we have to say the line.
 | 
					                        // It's a new death mark; we have to say the line.
 | 
				
			||||||
                        await createMessage(inventory.accountOwnerId.toString(), [
 | 
					                        await createMessage(inventory.accountOwnerId, [
 | 
				
			||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                sub: "/Lotus/Language/G1Quests/DeathMarkTitle",
 | 
					                                sub: "/Lotus/Language/G1Quests/DeathMarkTitle",
 | 
				
			||||||
                                sndr: "/Lotus/Language/G1Quests/DeathMarkSender",
 | 
					                                sndr: "/Lotus/Language/G1Quests/DeathMarkSender",
 | 
				
			||||||
 | 
				
			|||||||
@ -16,7 +16,7 @@ import {
 | 
				
			|||||||
    IQuestStage
 | 
					    IQuestStage
 | 
				
			||||||
} from "@/src/types/inventoryTypes/inventoryTypes";
 | 
					} from "@/src/types/inventoryTypes/inventoryTypes";
 | 
				
			||||||
import { logger } from "@/src/utils/logger";
 | 
					import { logger } from "@/src/utils/logger";
 | 
				
			||||||
import { HydratedDocument } from "mongoose";
 | 
					import { HydratedDocument, Types } from "mongoose";
 | 
				
			||||||
import { ExportKeys } from "warframe-public-export-plus";
 | 
					import { ExportKeys } from "warframe-public-export-plus";
 | 
				
			||||||
import { addFixedLevelRewards } from "./missionInventoryUpdateService";
 | 
					import { addFixedLevelRewards } from "./missionInventoryUpdateService";
 | 
				
			||||||
import { IInventoryChanges } from "../types/purchaseTypes";
 | 
					import { IInventoryChanges } from "../types/purchaseTypes";
 | 
				
			||||||
@ -107,7 +107,7 @@ export const addQuestKey = (
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (questKey.ItemType == "/Lotus/Types/Keys/InfestedMicroplanetQuest/InfestedMicroplanetQuestKeyChain") {
 | 
					    if (questKey.ItemType == "/Lotus/Types/Keys/InfestedMicroplanetQuest/InfestedMicroplanetQuestKeyChain") {
 | 
				
			||||||
        void createMessage(inventory.accountOwnerId.toString(), [
 | 
					        void createMessage(inventory.accountOwnerId, [
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                sndr: "/Lotus/Language/Bosses/Loid",
 | 
					                sndr: "/Lotus/Language/Bosses/Loid",
 | 
				
			||||||
                icon: "/Lotus/Interface/Icons/Npcs/Entrati/Loid.png",
 | 
					                icon: "/Lotus/Interface/Icons/Npcs/Entrati/Loid.png",
 | 
				
			||||||
@ -166,7 +166,7 @@ export const completeQuest = async (inventory: TInventoryDatabaseDocument, quest
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (chainStages[i].messageToSendWhenTriggered) {
 | 
					        if (chainStages[i].messageToSendWhenTriggered) {
 | 
				
			||||||
            await giveKeyChainMessage(inventory, inventory.accountOwnerId.toString(), {
 | 
					            await giveKeyChainMessage(inventory, inventory.accountOwnerId, {
 | 
				
			||||||
                KeyChain: questKey,
 | 
					                KeyChain: questKey,
 | 
				
			||||||
                ChainStage: i
 | 
					                ChainStage: i
 | 
				
			||||||
            });
 | 
					            });
 | 
				
			||||||
@ -238,7 +238,7 @@ export const giveKeyChainItem = async (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export const giveKeyChainMessage = async (
 | 
					export const giveKeyChainMessage = async (
 | 
				
			||||||
    inventory: TInventoryDatabaseDocument,
 | 
					    inventory: TInventoryDatabaseDocument,
 | 
				
			||||||
    accountId: string,
 | 
					    accountId: string | Types.ObjectId,
 | 
				
			||||||
    keyChainInfo: IKeyChainRequest
 | 
					    keyChainInfo: IKeyChainRequest
 | 
				
			||||||
): Promise<void> => {
 | 
					): Promise<void> => {
 | 
				
			||||||
    const keyChainMessage = getKeyChainMessage(keyChainInfo);
 | 
					    const keyChainMessage = getKeyChainMessage(keyChainInfo);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user