1 import * as express from 'express'
2 import { asyncMiddleware, authenticate } from '../../middlewares'
3 import { bulkRemoveCommentsOfValidator } from '@server/middlewares/validators/bulk'
4 import { VideoCommentModel } from '@server/models/video/video-comment'
5 import { BulkRemoveCommentsOfBody } from '@shared/models/bulk/bulk-remove-comments-of-body.model'
6 import { removeComment } from '@server/lib/video-comment'
8 const bulkRouter = express.Router()
10 bulkRouter.post('/remove-comments-of',
12 asyncMiddleware(bulkRemoveCommentsOfValidator),
13 asyncMiddleware(bulkRemoveCommentsOf)
16 // ---------------------------------------------------------------------------
22 // ---------------------------------------------------------------------------
24 async function bulkRemoveCommentsOf (req: express.Request, res: express.Response) {
25 const account = res.locals.account
26 const body = req.body as BulkRemoveCommentsOfBody
27 const user = res.locals.oauth.token.User
29 const filter = body.scope === 'my-videos'
30 ? { onVideosOfAccount: user.Account }
33 const comments = await VideoCommentModel.listForBulkDelete(account, filter)
38 for (const comment of comments) {
39 await removeComment(comment)