summary refs log tree commit diff
path: root/api/src/routes/channels/#channel_id/messages/index.ts
diff options
context:
space:
mode:
authorAlTech98 <altech123159@gmail.com>2021-09-18 18:36:29 +0200
committerAlTech98 <altech123159@gmail.com>2021-09-18 18:36:29 +0200
commitceb770fb5b6648c18d66d6997c8916ed60b8c192 (patch)
tree1995cbe4ec0dfe53860d8520b1de39ed4e02e0d6 /api/src/routes/channels/#channel_id/messages/index.ts
parentFix gateway not listening for new channels events (diff)
downloadserver-ceb770fb5b6648c18d66d6997c8916ed60b8c192.tar.xz
Removed ChannelService, more fixes
Diffstat (limited to 'api/src/routes/channels/#channel_id/messages/index.ts')
-rw-r--r--api/src/routes/channels/#channel_id/messages/index.ts6
1 files changed, 3 insertions, 3 deletions
diff --git a/api/src/routes/channels/#channel_id/messages/index.ts b/api/src/routes/channels/#channel_id/messages/index.ts
index bb610a6a..cde14164 100644
--- a/api/src/routes/channels/#channel_id/messages/index.ts
+++ b/api/src/routes/channels/#channel_id/messages/index.ts
@@ -1,5 +1,5 @@
 import { Router, Response, Request } from "express";
-import { Attachment, Channel, ChannelType, DmChannelDTO, Embed, emitEvent, getPermission, Message, MessageCreateEvent } from "@fosscord/util";
+import { Attachment, Channel, ChannelType, DmChannelDTO, Embed, emitEvent, getPermission, Message, MessageCreateEvent, Recipient } from "@fosscord/util";
 import { HTTPError } from "lambert-server";
 import { handleMessage, postHandleMessage, route } from "@fosscord/api";
 import multer from "multer";
@@ -150,7 +150,6 @@ router.post(
 				return res.status(400).json(error);
 			}
 		}
-		//TODO querying the DB at every message post should be avoided, caching maybe?
 		const channel = await Channel.findOneOrFail({ where: { id: channel_id }, relations: ["recipients", "recipients.user"] })
 
 		const embeds = [];
@@ -184,7 +183,8 @@ router.post(
 				}
 			}
 
-			await Promise.all(channel.recipients!.map(async r => {
+			//Only one recipients should be closed here, since in group DMs the recipient is deleted not closed
+			await Promise.all(channel.recipients!.filter(r => r.closed).map(async r => {
 				r.closed = false;
 				return await r.save()
 			}));