removeVideoCommentValidator,
videoCommentThreadsSortValidator
} from '../../../middlewares/validators'
removeVideoCommentValidator,
videoCommentThreadsSortValidator
} from '../../../middlewares/validators'
import { VideoCommentModel } from '../../../models/video/video-comment'
import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
import { AccountModel } from '../../../models/account/account'
import { VideoCommentModel } from '../../../models/video/video-comment'
import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger'
import { AccountModel } from '../../../models/account/account'
asyncMiddleware(listVideoThreads)
)
videoCommentRouter.get('/:videoId/comment-threads/:threadId',
asyncMiddleware(listVideoThreadCommentsValidator),
asyncMiddleware(listVideoThreads)
)
videoCommentRouter.get('/:videoId/comment-threads/:threadId',
asyncMiddleware(listVideoThreadCommentsValidator),
-async function listVideoThreads (req: express.Request, res: express.Response, next: express.NextFunction) {
- const video = res.locals.video as VideoModel
+async function listVideoThreads (req: express.Request, res: express.Response) {
+ const video = res.locals.video
+ const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
+
- resultList = await VideoCommentModel.listThreadsForApi(video.id, req.query.start, req.query.count, req.query.sort)
+ resultList = await VideoCommentModel.listThreadsForApi(video.id, req.query.start, req.query.count, req.query.sort, user)
-async function listVideoThreadComments (req: express.Request, res: express.Response, next: express.NextFunction) {
- const video = res.locals.video as VideoModel
+async function listVideoThreadComments (req: express.Request, res: express.Response) {
+ const video = res.locals.video
+ const user = res.locals.oauth ? res.locals.oauth.token.User : undefined
+
const videoCommentInfo: VideoCommentCreate = req.body
const comment = await sequelizeTypescript.transaction(async t => {
const videoCommentInfo: VideoCommentCreate = req.body
const comment = await sequelizeTypescript.transaction(async t => {
return createVideoComment({
text: videoCommentInfo.text,
return createVideoComment({
text: videoCommentInfo.text,
const videoCommentInfo: VideoCommentCreate = req.body
const comment = await sequelizeTypescript.transaction(async t => {
const videoCommentInfo: VideoCommentCreate = req.body
const comment = await sequelizeTypescript.transaction(async t => {
return createVideoComment({
text: videoCommentInfo.text,
return createVideoComment({
text: videoCommentInfo.text,
auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON()))
return res.json({ comment: comment.toFormattedJSON() }).end()
}
async function removeVideoComment (req: express.Request, res: express.Response) {
auditLogger.create(getAuditIdFromRes(res), new CommentAuditView(comment.toFormattedJSON()))
return res.json({ comment: comment.toFormattedJSON() }).end()
}
async function removeVideoComment (req: express.Request, res: express.Response) {
await sequelizeTypescript.transaction(async t => {
await videoCommentInstance.destroy({ transaction: t })
await sequelizeTypescript.transaction(async t => {
await videoCommentInstance.destroy({ transaction: t })