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: avoid softlocking the client when we couldn't mark email as read (#3240)

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

2e0f8a02
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

2 个文件 +7 -11
Modified src/controllers/api/inboxController.ts +7 -2
@@ -6,7 +6,6 @@ import {
6 6 deleteAllMessagesReadNonCin,
7 7 deleteMessageRead,
8 8 getAllMessagesSorted,
9 getMessage,
10 9 type IMessageCreationTemplate
11 10 } from "../../services/inboxService.ts";
12 11 import {
@@ -49,7 +48,13 @@ export const inboxController: RequestHandler = async (req, res) => {
49 48 }
50 49 res.status(200).end();
51 50 } else if (messageId) {
52 const message = await getMessage(parseOid(messageId as string));
51 const message = await Inbox.findById(parseOid(messageId as string));
52 if (!message) {
53 // in this case, we must send a 200 response to avoid softlocking the client
54 logger.warn(`client just read a message we don't know (anymore), attachments will not be received`);
55 res.end();
56 return;
57 }
53 58 message.r = true;
54 59 await message.save();
55 60
Modified src/services/inboxService.ts +0 -9
@@ -7,15 +7,6 @@ export const getAllMessagesSorted = async (accountId: string): Promise<HydratedD
7 7 return inbox;
8 8 };
9 9
10 export const getMessage = async (messageId: string): Promise<HydratedDocument<IMessageDatabase>> => {
11 const message = await Inbox.findById(messageId);
12
13 if (!message) {
14 throw new Error(`Message not found ${messageId}`);
15 }
16 return message;
17 };
18
19 10 export const deleteMessageRead = async (messageId: string): Promise<void> => {
20 11 await Inbox.findOneAndDelete({ _id: messageId, r: true });
21 12 };