gift received confirmation message
All checks were successful
Build / build (18) (push) Successful in 1m18s
Build / build (20) (push) Successful in 1m16s
Build / build (22) (push) Successful in 1m13s
Build / build (18) (pull_request) Successful in 1m14s
Build / build (20) (pull_request) Successful in 1m14s
Build / build (22) (pull_request) Successful in 1m13s

This commit is contained in:
Sainan 2025-03-27 13:03:28 +01:00
parent aab8411246
commit 44704ba6dd
2 changed files with 38 additions and 10 deletions

View File

@ -1,22 +1,24 @@
import { RequestHandler } from "express";
import { Inbox } from "@/src/models/inboxModel";
import {
createMessage,
createNewEventMessages,
deleteAllMessagesRead,
deleteMessageRead,
getAllMessagesSorted,
getMessage
} from "@/src/services/inboxService";
import { getAccountIdForRequest } from "@/src/services/loginService";
import { getAccountForRequest, getAccountFromSuffixedName, getSuffixedName } from "@/src/services/loginService";
import { addItems, combineInventoryChanges, getInventory } from "@/src/services/inventoryService";
import { logger } from "@/src/utils/logger";
import { ExportGear } from "warframe-public-export-plus";
import { ExportFlavour, ExportGear } from "warframe-public-export-plus";
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
export const inboxController: RequestHandler = async (req, res) => {
const { deleteId, lastMessage: latestClientMessageId, messageId } = req.query;
const accountId = await getAccountIdForRequest(req);
const account = await getAccountForRequest(req);
const accountId = account._id.toString();
if (deleteId) {
if (deleteId === "DeleteAllRead") {
@ -56,17 +58,39 @@ export const inboxController: RequestHandler = async (req, res) => {
await addItems(inventory, attachmentCountedItems, inventoryChanges);
}
if (message.gifts) {
const sender = await getAccountFromSuffixedName(message.sndr);
const recipientName = getSuffixedName(account);
const giftQuantity = message.arg!.find(x => x.Key == "GIFT_QUANTITY")!.Tag as number;
for (const gift of message.gifts) {
combineInventoryChanges(
inventoryChanges,
(
await handleStoreItemAcquisition(
gift.GiftType,
inventory,
message.arg!.find(x => x.Key == "GIFT_QUANTITY")!.Tag as number
)
).InventoryChanges
(await handleStoreItemAcquisition(gift.GiftType, inventory, giftQuantity)).InventoryChanges
);
if (sender) {
await createMessage(sender._id.toString(), [
{
sndr: recipientName,
msg: "/Lotus/Language/Menu/GiftReceivedConfirmationBody",
arg: [
{
Key: "RECIPIENT_NAME",
Tag: recipientName
},
{
Key: "GIFT_TYPE",
Tag: gift.GiftType
},
{
Key: "GIFT_QUANTITY",
Tag: giftQuantity
}
],
sub: "/Lotus/Language/Menu/GiftReceivedConfirmationSubject",
icon: ExportFlavour[inventory.ActiveAvatarImageType].icon,
highPriority: true
}
]);
}
}
}
await inventory.save();

View File

@ -100,3 +100,7 @@ export const getSuffixedName = (account: TAccountDocument): string => {
const suffix = ((crc32.str(name.toLowerCase() + "595") >>> 0) + platform_magics[platformId]) % 1000;
return name + "#" + suffix.toString().padStart(3, "0");
};
export const getAccountFromSuffixedName = (name: string): Promise<TAccountDocument | null> => {
return Account.findOne({ DisplayName: name.split("#")[0] });
};