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

XFESpaceNinjaServer

A simple server for a small space ninja game

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

XFEstudio/XFESpaceNinjaServer

chore: give back correct response for attempting to add a friend twice (#3225)

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

08b12f7b
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

1 个文件 +12 -5
Modified src/controllers/api/addPendingFriendController.ts +12 -5
@@ -7,6 +7,7 @@ import { getInventory } from "../../services/inventoryService.ts";
7 7 import { getAccountIdForRequest } from "../../services/loginService.ts";
8 8 import type { IFriendInfo } from "../../types/friendTypes.ts";
9 9 import type { RequestHandler, Response } from "express";
10 import { logger } from "../../utils/logger.ts";
10 11
11 12 export const addPendingFriendPostController: RequestHandler = async (req, res) => {
12 13 const accountId = await getAccountIdForRequest(req);
@@ -46,11 +47,17 @@ const sendFriendRequest = async (
46 47 return;
47 48 }
48 49
49 await Friendship.insertOne({
50 owner: accountId,
51 friend: account._id,
52 Note: message
53 });
50 try {
51 await Friendship.insertOne({
52 owner: accountId,
53 friend: account._id,
54 Note: message
55 });
56 } catch (e) {
57 logger.debug(`friend request failed due to ${String(e)}`);
58 res.status(400).send(`user ${name} already in friend list`);
59 return;
60 }
54 61
55 62 const friendInfo: IFriendInfo = {
56 63 _id: toOid(account._id),