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
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:
parent
aab8411246
commit
44704ba6dd
@ -1,22 +1,24 @@
|
|||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import { Inbox } from "@/src/models/inboxModel";
|
import { Inbox } from "@/src/models/inboxModel";
|
||||||
import {
|
import {
|
||||||
|
createMessage,
|
||||||
createNewEventMessages,
|
createNewEventMessages,
|
||||||
deleteAllMessagesRead,
|
deleteAllMessagesRead,
|
||||||
deleteMessageRead,
|
deleteMessageRead,
|
||||||
getAllMessagesSorted,
|
getAllMessagesSorted,
|
||||||
getMessage
|
getMessage
|
||||||
} from "@/src/services/inboxService";
|
} 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 { addItems, combineInventoryChanges, getInventory } from "@/src/services/inventoryService";
|
||||||
import { logger } from "@/src/utils/logger";
|
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";
|
import { handleStoreItemAcquisition } from "@/src/services/purchaseService";
|
||||||
|
|
||||||
export const inboxController: RequestHandler = async (req, res) => {
|
export const inboxController: RequestHandler = async (req, res) => {
|
||||||
const { deleteId, lastMessage: latestClientMessageId, messageId } = req.query;
|
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) {
|
||||||
if (deleteId === "DeleteAllRead") {
|
if (deleteId === "DeleteAllRead") {
|
||||||
@ -56,17 +58,39 @@ export const inboxController: RequestHandler = async (req, res) => {
|
|||||||
await addItems(inventory, attachmentCountedItems, inventoryChanges);
|
await addItems(inventory, attachmentCountedItems, inventoryChanges);
|
||||||
}
|
}
|
||||||
if (message.gifts) {
|
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) {
|
for (const gift of message.gifts) {
|
||||||
combineInventoryChanges(
|
combineInventoryChanges(
|
||||||
inventoryChanges,
|
inventoryChanges,
|
||||||
(
|
(await handleStoreItemAcquisition(gift.GiftType, inventory, giftQuantity)).InventoryChanges
|
||||||
await handleStoreItemAcquisition(
|
|
||||||
gift.GiftType,
|
|
||||||
inventory,
|
|
||||||
message.arg!.find(x => x.Key == "GIFT_QUANTITY")!.Tag as number
|
|
||||||
)
|
|
||||||
).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();
|
await inventory.save();
|
||||||
|
@ -100,3 +100,7 @@ export const getSuffixedName = (account: TAccountDocument): string => {
|
|||||||
const suffix = ((crc32.str(name.toLowerCase() + "595") >>> 0) + platform_magics[platformId]) % 1000;
|
const suffix = ((crc32.str(name.toLowerCase() + "595") >>> 0) + platform_magics[platformId]) % 1000;
|
||||||
return name + "#" + suffix.toString().padStart(3, "0");
|
return name + "#" + suffix.toString().padStart(3, "0");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getAccountFromSuffixedName = (name: string): Promise<TAccountDocument | null> => {
|
||||||
|
return Account.findOne({ DisplayName: name.split("#")[0] });
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user