返回提交历史
Modified
src/controllers/api/getFriendsController.ts
+6
-5
Modified
src/controllers/stats/viewController.ts
+1
-2
Modified
src/routes/stats.ts
+1
-0
XFEstudio/SpaceNinjaServer
feat: profileStats endpoint for U8 (#3003)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3003 Reviewed-by: Sainan <63328889+sainan@users.noreply.github.com> Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
e58655e3
代码差异
3 个文件
+8
-7
@@ -1,13 +1,14 @@
1
import { toOid } from "../../helpers/inventoryHelpers.ts";
1
import { toOid2 } from "../../helpers/inventoryHelpers.ts";
2
2
import { Friendship } from "../../models/friendModel.ts";
3
3
import { addAccountDataToFriendInfo, addInventoryDataToFriendInfo } from "../../services/friendService.ts";
4
import { getAccountIdForRequest } from "../../services/loginService.ts";
4
import { getAccountForRequest } from "../../services/loginService.ts";
5
5
import type { IFriendInfo } from "../../types/friendTypes.ts";
6
6
import type { Request, RequestHandler, Response } from "express";
7
7
8
8
// POST with {} instead of GET as of 38.5.0
9
9
export const getFriendsController: RequestHandler = async (req: Request, res: Response) => {
10
const accountId = await getAccountIdForRequest(req);
10
const account = await getAccountForRequest(req);
11
const accountId = account._id.toString();
11
12
const response: IGetFriendsResponse = {
12
13
Current: [],
13
14
IncomingFriendRequests: [],
@@ -20,14 +21,14 @@ export const getFriendsController: RequestHandler = async (req: Request, res: Re
20
21
for (const externalFriendship of externalFriendships) {
21
22
if (!internalFriendships.find(x => x.friend.equals(externalFriendship.owner))) {
22
23
response.IncomingFriendRequests.push({
23
_id: toOid(externalFriendship.owner),
24
_id: toOid2(externalFriendship.owner, account.BuildLabel),
24
25
Note: externalFriendship.Note
25
26
});
26
27
}
27
28
}
28
29
for (const internalFriendship of internalFriendships) {
29
30
const friendInfo: IFriendInfo = {
30
_id: toOid(internalFriendship.friend)
31
_id: toOid2(internalFriendship.friend, account.BuildLabel)
31
32
};
32
33
if (externalFriendships.find(x => x.owner.equals(internalFriendship.friend))) {
33
34
response.Current.push(friendInfo);
@@ -1,11 +1,10 @@
1
1
import type { RequestHandler } from "express";
2
import { getAccountIdForRequest } from "../../services/loginService.ts";
3
2
import { getInventory } from "../../services/inventoryService.ts";
4
3
import { getStats } from "../../services/statsService.ts";
5
4
import type { IStatsClient } from "../../types/statTypes.ts";
6
5
7
6
const viewController: RequestHandler = async (req, res) => {
8
const accountId = await getAccountIdForRequest(req);
7
const accountId = String(req.query.id ?? req.query.lookupId);
9
8
const inventory = await getInventory(accountId, "XPInfo");
10
9
const playerStats = await getStats(accountId);
11
10
@@ -6,6 +6,7 @@ import { leaderboardController } from "../controllers/stats/leaderboardControlle
6
6
const statsRouter = express.Router();
7
7
8
8
statsRouter.get("/view.php", viewController);
9
statsRouter.get("/profileStats.php", viewController);
9
10
statsRouter.post("/upload.php", uploadController);
10
11
statsRouter.post("/leaderboardWeekly.php", leaderboardController);
11
12
statsRouter.post("/leaderboardArchived.php", leaderboardController);