返回提交历史
Modified
src/controllers/api/addFriendController.ts
+1
-1
Modified
src/services/friendService.ts
+11
-3
XFEstudio/XFESpaceNinjaServer
fix: addFriend response for U40 (#3613)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3613 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
f46d7428
代码差异
2 个文件
+12
-4
@@ -40,7 +40,7 @@ export const addFriendPostController: RequestHandler = async (req, res) => {
40
40
const requesterUsesNrsNotifications =
41
41
account.BuildLabel && version_compare(account.BuildLabel, gameToBuildVersion["40.0.0"]) < 0;
42
42
for (const newFriend of newFriends) {
43
promises.push(addAccountDataToFriendInfo(newFriend, account.BuildLabel));
43
promises.push(addAccountDataToFriendInfo(newFriend, account.BuildLabel, !requesterUsesNrsNotifications));
44
44
promises.push(addInventoryDataToFriendInfo(newFriend));
45
45
if (!requesterUsesNrsNotifications) {
46
46
void Account.findById(fromOid(newFriend._id), "BuildLabel").then(newFriendAcct => {
@@ -4,10 +4,18 @@ import { Account } from "../models/loginModel.ts";
4
4
import type { Types } from "mongoose";
5
5
import { Friendship } from "../models/friendModel.ts";
6
6
import { fromOid, toMongoDate2 } from "../helpers/inventoryHelpers.ts";
7
import { getUnicodeName } from "./loginService.ts";
7
8
8
export const addAccountDataToFriendInfo = async (info: IFriendInfo, buildLabel: string | undefined): Promise<void> => {
9
const account = (await Account.findById(fromOid(info._id), "DisplayName LastLogin LastPlatform"))!;
10
info.DisplayName = account.DisplayName;
9
export const addAccountDataToFriendInfo = async (
10
info: IFriendInfo,
11
buildLabel: string | undefined,
12
useUnicodeName?: boolean
13
): Promise<void> => {
14
const account = (await Account.findById(
15
fromOid(info._id),
16
useUnicodeName ? undefined : "DisplayName LastLogin LastPlatform"
17
))!;
18
info.DisplayName = useUnicodeName ? getUnicodeName(account, buildLabel) : account.DisplayName;
11
19
info.LastLogin = toMongoDate2(account.LastLogin, buildLabel);
12
20
info.LastPlatform = account.LastPlatform;
13
21
};