1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-12-25 13:08:51 +00:00

Add a check

This commit is contained in:
Pierre HUBERT 2020-07-10 08:04:41 +02:00
parent c9646f8b30
commit 63953587f8

View File

@ -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