From 63953587f84b0d0dad09ef58aadae532cab47585 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 10 Jul 2020 08:04:41 +0200 Subject: [PATCH] Add a check --- src/controllers/CommentsController.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/controllers/CommentsController.ts b/src/controllers/CommentsController.ts index 1b53fac..470fd23 100644 --- a/src/controllers/CommentsController.ts +++ b/src/controllers/CommentsController.ts @@ -7,6 +7,7 @@ import { CommentsHelper } from "../helpers/CommentsHelper"; import { NotifEventType } from "../entities/Notification"; import { NotificationsHelper } from "../helpers/NotificationsHelper"; import { AbstractUserConnectionContainer } from "../entities/UserConnectionContainer"; +import { PostsHelper } from "../helpers/PostsHelper"; /** * Comments controller @@ -24,6 +25,11 @@ export class CommentsController { public static async Create(h: RequestHandler) { const postID = await h.postPostIDWithAccess("postID"); + // Check if the post allows comments + if(!await PostsHelper.AllowCommentsOnPost(await PostsHelper.GetSingle(postID))) { + h.error(401, "You can not create comments on this post!"); + } + let content: string, image_path: string; // Check if an image was included in the request or not