X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fvideos%2Fcomment.ts;h=44d64776c60a351232c4ea9b3cf547a2f3c28b81;hb=44e702ded455c118f9908b70d25e7c7e5512abe9;hp=cfdf2773f634b145c955165610a0d313b1f1eea0;hpb=1c5e49e75284100b7b1fc8b4e73c8ba53fe22e89;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index cfdf2773f..44d64776c 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts @@ -1,7 +1,7 @@ -import * as express from 'express' -import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' -import { ResultList, ThreadsResultList, UserRight } from '../../../../shared/models' -import { VideoCommentCreate } from '../../../../shared/models/videos/comment/video-comment.model' +import express from 'express' +import { ResultList, ThreadsResultList, UserRight, VideoCommentCreate } from '../../../../shared/models' +import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' +import { VideoCommentThreads } from '../../../../shared/models/videos/comment/video-comment.model' import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' import { getFormattedObjects } from '../../../helpers/utils' import { sequelizeTypescript } from '../../../initializers/database' @@ -91,6 +91,7 @@ async function listComments (req: express.Request, res: express.Response) { sort: req.query.sort, isLocal: req.query.isLocal, + onLocalVideo: req.query.onLocalVideo, search: req.query.search, searchAccount: req.query.searchAccount, searchVideo: req.query.searchVideo @@ -136,7 +137,7 @@ async function listVideoThreads (req: express.Request, res: express.Response) { return res.json({ ...getFormattedObjects(resultList.data, resultList.total), totalNotDeletedComments: resultList.totalNotDeletedComments - }) + } as VideoCommentThreads) } async function listVideoThreadComments (req: express.Request, res: express.Response) { @@ -166,7 +167,10 @@ async function listVideoThreadComments (req: express.Request, res: express.Respo } if (resultList.data.length === 0) { - return res.sendStatus(HttpStatusCode.NOT_FOUND_404) + return res.fail({ + status: HttpStatusCode.NOT_FOUND_404, + message: 'No comments were found' + }) } return res.json(buildFormattedCommentTree(resultList)) @@ -189,7 +193,7 @@ async function addVideoCommentThread (req: express.Request, res: express.Respons Notifier.Instance.notifyOnNewComment(comment) auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON())) - Hooks.runAction('action:api.video-thread.created', { comment }) + Hooks.runAction('action:api.video-thread.created', { comment, req, res }) return res.json({ comment: comment.toFormattedJSON() }) } @@ -211,7 +215,7 @@ async function addVideoCommentReply (req: express.Request, res: express.Response Notifier.Instance.notifyOnNewComment(comment) auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON())) - Hooks.runAction('action:api.video-comment-reply.created', { comment }) + Hooks.runAction('action:api.video-comment-reply.created', { comment, req, res }) return res.json({ comment: comment.toFormattedJSON() }) } @@ -219,7 +223,7 @@ async function addVideoCommentReply (req: express.Request, res: express.Response async function removeVideoComment (req: express.Request, res: express.Response) { const videoCommentInstance = res.locals.videoCommentFull - await removeComment(videoCommentInstance) + await removeComment(videoCommentInstance, req, res) auditLogger.delete(getAuditIdFromRes(res), new CommentAuditView(videoCommentInstance.toFormattedJSON()))