import * as express from 'express'
+import { JobQueue } from '@server/lib/job-queue'
+import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
import { UserRight } from '../../../../shared/models/users'
+import { logger } from '../../../helpers/logger'
+import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy'
import {
asyncMiddleware,
authenticate,
videoRedundanciesSortValidator
} from '../../../middlewares'
import {
- listVideoRedundanciesValidator,
- updateServerRedundancyValidator,
addVideoRedundancyValidator,
- removeVideoRedundancyValidator
+ listVideoRedundanciesValidator,
+ removeVideoRedundancyValidator,
+ updateServerRedundancyValidator
} from '../../../middlewares/validators/redundancy'
-import { removeRedundanciesOfServer, removeVideoRedundancy } from '../../../lib/redundancy'
-import { logger } from '../../../helpers/logger'
-import { VideoRedundancyModel } from '@server/models/redundancy/video-redundancy'
-import { JobQueue } from '@server/lib/job-queue'
const serverRedundancyRouter = express.Router()
videoId: res.locals.onlyVideo.id
}
- await JobQueue.Instance.createJob({
+ await JobQueue.Instance.createJobWithPromise({
type: 'video-redundancy',
payload
})
- return res.sendStatus(204)
+ return res.status(HttpStatusCode.NO_CONTENT_204).end()
}
async function removeVideoRedundancyController (req: express.Request, res: express.Response) {
await removeVideoRedundancy(res.locals.videoRedundancy)
- return res.sendStatus(204)
+ return res.status(HttpStatusCode.NO_CONTENT_204).end()
}
async function updateRedundancy (req: express.Request, res: express.Response) {
removeRedundanciesOfServer(server.id)
.catch(err => logger.error('Cannot remove redundancy of %s.', server.host, { err }))
- return res.sendStatus(204)
+ return res.status(HttpStatusCode.NO_CONTENT_204).end()
}