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