XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

chore: remove needless query when sending clan invite (#1434)

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/1434 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

92cf8508
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

1 个文件 +8 -12
Modified src/controllers/api/addToGuildController.ts +8 -12
@@ -35,22 +35,18 @@ export const addToGuildController: RequestHandler = async (req, res) => {
35 35 res.status(400).json("Invalid permission");
36 36 }
37 37
38 if (
39 await GuildMember.exists({
38 try {
39 await GuildMember.insertOne({
40 40 accountId: account._id,
41 guildId: payload.GuildId.$oid
42 })
43 ) {
41 guildId: payload.GuildId.$oid,
42 status: 2 // outgoing invite
43 });
44 } catch (e) {
45 logger.debug(`guild invite failed due to ${String(e)}`);
44 46 res.status(400).json("User already invited to clan");
45 47 return;
46 48 }
47 49
48 await GuildMember.insertOne({
49 accountId: account._id,
50 guildId: payload.GuildId.$oid,
51 status: 2 // outgoing invite
52 });
53
54 50 const senderInventory = await getInventory(senderAccount._id.toString(), "ActiveAvatarImageType");
55 51 await createMessage(account._id, [
56 52 {
@@ -92,7 +88,7 @@ export const addToGuildController: RequestHandler = async (req, res) => {
92 88 RequestExpiry: new Date(Date.now() + 14 * 86400 * 1000) // TOVERIFY: I can't find any good information about this with regards to live, but 2 weeks seem reasonable.
93 89 });
94 90 } catch (e) {
95 // Assuming this is "E11000 duplicate key error" due to the guildId-accountId unique index.
91 logger.debug(`alliance invite failed due to ${String(e)}`);
96 92 res.status(400).send("Already requested");
97 93 }
98 94 res.end();