返回提交历史
Modified
src/controllers/api/confirmAllianceInvitationController.ts
+4
-4
Modified
src/controllers/api/getAllianceController.ts
+4
-4
Modified
src/controllers/custom/getAllianceController.ts
+1
-1
Modified
src/services/guildService.ts
+3
-3
XFEstudio/XFESpaceNinjaServer
fix: respect BuildLabel for getAlliance (#3609)
Closes #3601 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/3609 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
a6b7e4e1
代码差异
4 个文件
+12
-12
@@ -1,12 +1,12 @@
1
1
import { Alliance, AllianceMember, Guild, GuildMember } from "../../models/guildModel.ts";
2
2
import { getAllianceClient } from "../../services/guildService.ts";
3
import { getAccountIdForRequest } from "../../services/loginService.ts";
3
import { getAccountForRequest } from "../../services/loginService.ts";
4
4
import type { RequestHandler } from "express";
5
5
6
6
export const confirmAllianceInvitationController: RequestHandler = async (req, res) => {
7
7
// Check requester is a warlord in their guild
8
const accountId = await getAccountIdForRequest(req);
9
const guildMember = (await GuildMember.findOne({ accountId, status: 0 }))!;
8
const account = await getAccountForRequest(req);
9
const guildMember = (await GuildMember.findOne({ accountId: account._id, status: 0 }))!;
10
10
if (guildMember.rank > 1) {
11
11
res.status(400).json({ Error: 104 });
12
12
return;
@@ -29,7 +29,7 @@ export const confirmAllianceInvitationController: RequestHandler = async (req, r
29
29
30
30
// Give client the new alliance data which uses "AllianceId" instead of "_id" in this response
31
31
const alliance = (await Alliance.findById(allianceMember.allianceId))!;
32
const { _id, ...rest } = await getAllianceClient(alliance, guild);
32
const { _id, ...rest } = await getAllianceClient(alliance, guild, account.BuildLabel);
33
33
res.json({
34
34
AllianceId: _id,
35
35
...rest
@@ -1,17 +1,17 @@
1
1
import { Alliance, Guild } from "../../models/guildModel.ts";
2
2
import { getAllianceClient } from "../../services/guildService.ts";
3
3
import { getInventory } from "../../services/inventoryService.ts";
4
import { getAccountIdForRequest } from "../../services/loginService.ts";
4
import { getAccountForRequest } from "../../services/loginService.ts";
5
5
import type { RequestHandler } from "express";
6
6
7
7
export const getAllianceController: RequestHandler = async (req, res) => {
8
const accountId = await getAccountIdForRequest(req);
9
const inventory = await getInventory(accountId, "GuildId");
8
const account = await getAccountForRequest(req);
9
const inventory = await getInventory(account._id, "GuildId");
10
10
if (inventory.GuildId) {
11
11
const guild = (await Guild.findById(inventory.GuildId, "Name Tier AllianceId"))!;
12
12
if (guild.AllianceId) {
13
13
const alliance = (await Alliance.findById(guild.AllianceId))!;
14
res.json(await getAllianceClient(alliance, guild));
14
res.json(await getAllianceClient(alliance, guild, account.BuildLabel));
15
15
return;
16
16
}
17
17
}
@@ -8,7 +8,7 @@ export const getAllianceController: RequestHandler = async (req, res) => {
8
8
const guild = await Guild.findById(guildId, "Name Tier AllianceId");
9
9
if (guild && guild.AllianceId) {
10
10
const alliance = (await Alliance.findById(guild.AllianceId))!;
11
res.json(await getAllianceClient(alliance, guild));
11
res.json(await getAllianceClient(alliance, guild, undefined));
12
12
return;
13
13
}
14
14
}
@@ -22,7 +22,7 @@ import type {
22
22
ITechProjectDatabase
23
23
} from "../types/guildTypes.ts";
24
24
import { GuildPermission } from "../types/guildTypes.ts";
25
import { toMongoDate, toOid, toOid2, version_compare } from "../helpers/inventoryHelpers.ts";
25
import { toMongoDate, toOid2, version_compare } from "../helpers/inventoryHelpers.ts";
26
26
import type { Types } from "mongoose";
27
27
import type { IDojoBuild, IDojoResearch } from "warframe-public-export-plus";
28
28
import { ExportDojoRecipes, ExportResources } from "warframe-public-export-plus";
@@ -858,7 +858,7 @@ export const deleteAlliance = async (allianceId: Types.ObjectId): Promise<void>
858
858
export const getAllianceClient = async (
859
859
alliance: IAllianceDatabase,
860
860
guild: TGuildDatabaseDocument,
861
buildLabel?: string
861
buildLabel: string | undefined
862
862
): Promise<IAllianceClient> => {
863
863
const allianceMembers = await AllianceMember.find({ allianceId: alliance._id });
864
864
const clans: IAllianceMemberClient[] = [];
@@ -867,7 +867,7 @@ export const getAllianceClient = async (
867
867
? guild
868
868
: (await Guild.findById(allianceMember.guildId))!;
869
869
clans.push({
870
_id: toOid(allianceMember.guildId),
870
_id: toOid2(allianceMember.guildId, buildLabel),
871
871
Name: memberGuild.Name,
872
872
Tier: memberGuild.Tier,
873
873
Pending: allianceMember.Pending,