From af97216c136287bb7a26968b3ec4789004f316cb Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 30 Nov 2019 19:58:00 +0100 Subject: [PATCH] Can send image in conversation messages --- src/controllers/ConversationsController.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/controllers/ConversationsController.ts b/src/controllers/ConversationsController.ts index b98d597..6f0141b 100644 --- a/src/controllers/ConversationsController.ts +++ b/src/controllers/ConversationsController.ts @@ -210,8 +210,15 @@ export class ConversationsController { public static async SendMessage(h: RequestHandler) { const convID = await this.GetPostConversationId("conversationID", h); const message = removeHTMLNodes(h.postString("message", 0)); + let imagePath = ""; - if(message.length < 3) + // Check for image + if(h.hasFile("image")){ + // Try to save image + imagePath = await h.savePostImage("image", "conversations", 1200, 1200); + } + + else if(message.length < 3) h.error(401, "Message is empty!"); // Send message @@ -219,7 +226,7 @@ export class ConversationsController { userID: h.getUserId(), convID: convID, message: message, - imagePath: "" + imagePath: imagePath }); h.success("Conversation message was sent!");