返回提交历史
Modified
src/controllers/api/addToGuildController.ts
+1
-1
Modified
src/controllers/api/confirmGuildInvitationController.ts
+1
-1
Modified
src/controllers/api/contributeGuildClassController.ts
+1
-1
Modified
src/controllers/api/getGuildController.ts
+1
-1
Modified
src/controllers/api/getGuildDojoController.ts
+1
-1
Modified
src/controllers/api/getGuildLogController.ts
+1
-1
Modified
src/controllers/api/logoutController.ts
+1
-1
Modified
src/controllers/api/removeFromGuildController.ts
+1
-1
Modified
src/controllers/api/setGuildMotdController.ts
+1
-1
Modified
src/controllers/custom/getAccountInfoController.ts
+1
-1
Modified
src/controllers/dynamic/getProfileViewingDataController.ts
+3
-3
Modified
src/services/guildService.ts
+1
-1
Modified
src/services/inboxService.ts
+1
-1
Modified
src/services/shipService.ts
+1
-1
XFEstudio/XFESpaceNinjaServer
chore: use model.findById where possible (#1315)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1315
2ec2b027
代码差异
14 个文件
+16
-16
@@ -18,7 +18,7 @@ export const addToGuildController: RequestHandler = async (req, res) => {
18
18
return;
19
19
}
20
20
21
const guild = (await Guild.findOne({ _id: payload.GuildId.$oid }, "Name"))!;
21
const guild = (await Guild.findById(payload.GuildId.$oid, "Name"))!;
22
22
const senderAccount = await getAccountForRequest(req);
23
23
if (!(await hasGuildPermission(guild, senderAccount._id.toString(), GuildPermission.Recruiter))) {
24
24
res.status(400).json("Invalid permission");
@@ -19,7 +19,7 @@ export const confirmGuildInvitationController: RequestHandler = async (req, res)
19
19
new Types.ObjectId(req.query.clanId as string)
20
20
);
21
21
22
const guild = (await Guild.findOne({ _id: req.query.clanId as string }))!;
22
const guild = (await Guild.findById(req.query.clanId as string))!;
23
23
24
24
guild.RosterActivity ??= [];
25
25
guild.RosterActivity.push({
@@ -11,7 +11,7 @@ import { Types } from "mongoose";
11
11
export const contributeGuildClassController: RequestHandler = async (req, res) => {
12
12
const accountId = await getAccountIdForRequest(req);
13
13
const payload = getJSONfromString<IContributeGuildClassRequest>(String(req.body));
14
const guild = (await Guild.findOne({ _id: payload.GuildId }))!;
14
const guild = (await Guild.findById(payload.GuildId))!;
15
15
16
16
// First contributor initiates ceremony and locks the pending class.
17
17
if (!guild.CeremonyContributors) {
@@ -9,7 +9,7 @@ const getGuildController: RequestHandler = async (req, res) => {
9
9
const accountId = await getAccountIdForRequest(req);
10
10
const inventory = await getInventory(accountId, "GuildId");
11
11
if (inventory.GuildId) {
12
const guild = await Guild.findOne({ _id: inventory.GuildId });
12
const guild = await Guild.findById(inventory.GuildId);
13
13
if (guild) {
14
14
// Handle guilds created before we added discriminators
15
15
if (guild.Name.indexOf("#") == -1) {
@@ -6,7 +6,7 @@ import { getDojoClient } from "@/src/services/guildService";
6
6
export const getGuildDojoController: RequestHandler = async (req, res) => {
7
7
const guildId = req.query.guildId as string;
8
8
9
const guild = await Guild.findOne({ _id: guildId });
9
const guild = await Guild.findById(guildId);
10
10
if (!guild) {
11
11
res.status(404).end();
12
12
return;
@@ -9,7 +9,7 @@ export const getGuildLogController: RequestHandler = async (req, res) => {
9
9
const accountId = await getAccountIdForRequest(req);
10
10
const inventory = await getInventory(accountId, "GuildId");
11
11
if (inventory.GuildId) {
12
const guild = await Guild.findOne({ _id: inventory.GuildId });
12
const guild = await Guild.findById(inventory.GuildId);
13
13
if (guild) {
14
14
const log: Record<string, IGuildLogEntryClient[]> = {
15
15
RoomChanges: [],
@@ -4,7 +4,7 @@ import { Account } from "@/src/models/loginModel";
4
4
5
5
const logoutController: RequestHandler = async (req, res) => {
6
6
const accountId = await getAccountIdForRequest(req);
7
const account = await Account.findOne({ _id: accountId });
7
const account = await Account.findById(accountId);
8
8
if (account) {
9
9
account.Nonce = 0;
10
10
await account.save();
@@ -42,7 +42,7 @@ export const removeFromGuildController: RequestHandler = async (req, res) => {
42
42
43
43
guild.RosterActivity ??= [];
44
44
if (isKick) {
45
const kickee = (await Account.findOne({ _id: payload.userId }))!;
45
const kickee = (await Account.findById(payload.userId))!;
46
46
guild.RosterActivity.push({
47
47
dateTime: new Date(),
48
48
entryType: 12,
@@ -8,7 +8,7 @@ import { RequestHandler } from "express";
8
8
export const setGuildMotdController: RequestHandler = async (req, res) => {
9
9
const account = await getAccountForRequest(req);
10
10
const inventory = await getInventory(account._id.toString(), "GuildId");
11
const guild = (await Guild.findOne({ _id: inventory.GuildId! }))!;
11
const guild = (await Guild.findById(inventory.GuildId!))!;
12
12
if (!(await hasGuildPermission(guild, account._id, GuildPermission.Herald))) {
13
13
res.status(400).json("Invalid permission");
14
14
return;
@@ -12,7 +12,7 @@ export const getAccountInfoController: RequestHandler = async (req, res) => {
12
12
}
13
13
const guildMember = await GuildMember.findOne({ accountId: account._id, status: 0 }, "guildId rank");
14
14
if (guildMember) {
15
const guild = (await Guild.findOne({ _id: guildMember.guildId }, "Ranks"))!;
15
const guild = (await Guild.findById(guildMember.guildId, "Ranks"))!;
16
16
info.GuildId = guildMember.guildId.toString();
17
17
info.GuildPermissions = guild.Ranks[guildMember.rank].Permissions;
18
18
}
@@ -26,13 +26,13 @@ export const getProfileViewingDataController: RequestHandler = async (req, res)
26
26
res.status(400).end();
27
27
return;
28
28
}
29
const account = await Account.findOne({ _id: req.query.playerId as string }, "DisplayName");
29
const account = await Account.findById(req.query.playerId as string, "DisplayName");
30
30
if (!account) {
31
31
res.status(400).send("No account or guild ID specified");
32
32
return;
33
33
}
34
34
const inventory = (await Inventory.findOne({ accountOwnerId: account._id }))!;
35
const loadout = (await Loadout.findOne({ _id: inventory.LoadOutPresets }, "NORMAL"))!;
35
const loadout = (await Loadout.findById(inventory.LoadOutPresets, "NORMAL"))!;
36
36
37
37
const result: IPlayerProfileViewingDataResult = {
38
38
AccountId: toOid(account._id),
@@ -88,7 +88,7 @@ export const getProfileViewingDataController: RequestHandler = async (req, res)
88
88
}
89
89
}
90
90
if (inventory.GuildId) {
91
const guild = (await Guild.findOne({ _id: inventory.GuildId }, "Name Tier XP Class"))!;
91
const guild = (await Guild.findById(inventory.GuildId, "Name Tier XP Class"))!;
92
92
result.GuildId = toOid(inventory.GuildId);
93
93
result.GuildName = guild.Name;
94
94
result.GuildTier = guild.Tier;
@@ -37,7 +37,7 @@ export const getGuildForRequestEx = async (
37
37
if (!inventory.GuildId || inventory.GuildId.toString() != guildId) {
38
38
throw new Error("Account is not in the guild that it has sent a request for");
39
39
}
40
const guild = await Guild.findOne({ _id: guildId });
40
const guild = await Guild.findById(guildId);
41
41
if (!guild) {
42
42
throw new Error("Account thinks it is in a guild that doesn't exist");
43
43
}