返回提交历史
Modified
src/controllers/api/inventoryController.ts
+2
-2
Modified
src/services/inboxService.ts
+12
-4
XFEstudio/XFESpaceNinjaServer
fix: respect buildLabel when building Mailbox for inventory json (#4012)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4012 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
86345270
代码差异
2 个文件
+14
-6
@@ -65,7 +65,7 @@ import { DailyDeal } from "../../models/worldStateModel.ts";
65
65
import { EquipmentFeatures } from "../../types/equipmentTypes.ts";
66
66
import { generateRewardSeed } from "../../services/rngService.ts";
67
67
import { getInvasionByOid, getWorldState } from "../../services/worldStateService.ts";
68
import { createMessage } from "../../services/inboxService.ts";
68
import { createMessage, getInboxFilter } from "../../services/inboxService.ts";
69
69
import gameToBuildVersion from "../../constants/gameToBuildVersion.ts";
70
70
import { PendingTrade } from "../../models/tradingModel.ts";
71
71
import { exportTrade } from "../../services/tradingService.ts";
@@ -369,7 +369,7 @@ export const getInventoryResponse = async (
369
369
const [inventoryWithLoadOutPresets, ships, latestMessage, pendingTrades] = await Promise.all([
370
370
inventory.populate<{ LoadOutPresets: ILoadoutDatabase }>("LoadOutPresets"),
371
371
Ship.find({ ShipOwnerId: inventory.accountOwnerId }),
372
Inbox.findOne({ ownerId: inventory.accountOwnerId }, "_id").sort({ date: -1 }),
372
Inbox.findOne(getInboxFilter(inventory.accountOwnerId, buildLabel), "_id").sort({ date: -1 }),
373
373
PendingTrade.find({ $or: [{ a: inventory.accountOwnerId }, { b: inventory.accountOwnerId }] })
374
374
]);
375
375
const inventoryResponse = inventoryWithLoadOutPresets.toJSON<IInventoryClient>();
@@ -4,11 +4,10 @@ import { Inbox } from "../models/inboxModel.ts";
4
4
import type { QueryFilter, Types } from "mongoose";
5
5
import { buildVersionToInt } from "./loginService.ts";
6
6
7
export const getMessagesSorted = async (
7
export const getInboxFilter = (
8
8
accountId: string | Types.ObjectId,
9
buildLabel: string | undefined,
10
afterId?: string | Types.ObjectId
11
): Promise<TMessageDocument[]> => {
9
buildLabel: string | undefined
10
): QueryFilter<IMessageDatabase> => {
12
11
const query: QueryFilter<IMessageDatabase> = { ownerId: accountId };
13
12
if (buildLabel) {
14
13
query.$or = [
@@ -16,6 +15,15 @@ export const getMessagesSorted = async (
16
15
{ minBuildVersion: { $lte: buildVersionToInt(buildLabel) } }
17
16
];
18
17
}
18
return query;
19
};
20
21
export const getMessagesSorted = async (
22
accountId: string | Types.ObjectId,
23
buildLabel: string | undefined,
24
afterId?: string | Types.ObjectId
25
): Promise<TMessageDocument[]> => {
26
const query = getInboxFilter(accountId, buildLabel);
19
27
if (afterId) {
20
28
query._id = { $gt: afterId };
21
29
}