]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/videos/comment.ts
Support studio transcoding in peertube runner
[github/Chocobozzz/PeerTube.git] / server / controllers / api / videos / comment.ts
index 90b633bb51d3ab1f9ec1939dcf16199f0adff8e5..70ca21500a43c2530fd80e2e8a85014f1a012287 100644 (file)
@@ -1,6 +1,8 @@
-import * as express from 'express'
-import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
+import { MCommentFormattable } from '@server/types/models'
+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'
@@ -91,6 +93,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
@@ -108,7 +111,7 @@ async function listVideoThreads (req: express.Request, res: express.Response) {
   const video = res.locals.onlyVideo
   const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
 
-  let resultList: ThreadsResultList<VideoCommentModel>
+  let resultList: ThreadsResultList<MCommentFormattable>
 
   if (video.commentsEnabled === true) {
     const apiOptions = await Hooks.wrapObject({
@@ -143,12 +146,11 @@ async function listVideoThreadComments (req: express.Request, res: express.Respo
   const video = res.locals.onlyVideo
   const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
 
-  let resultList: ResultList<VideoCommentModel>
+  let resultList: ResultList<MCommentFormattable>
 
   if (video.commentsEnabled === true) {
     const apiOptions = await Hooks.wrapObject({
       videoId: video.id,
-      isVideoOwned: video.isOwned(),
       threadId: res.locals.videoCommentThread.id,
       user
     }, 'filter:api.video-thread-comments.list.params')
@@ -192,7 +194,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() })
 }
@@ -214,7 +216,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() })
 }
@@ -222,7 +224,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()))