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!");