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