1
0
Fork 0
peertube/server/middlewares/validators/shared/video-ownerships.ts
Chocobozzz 10363c74c1
Move middleware utils in middlewares
helpers modules should not import models
2021-06-03 18:03:36 +02:00

24 lines
669 B
TypeScript

import * as express from 'express'
import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership'
import { HttpStatusCode } from '@shared/core-utils'
async function doesChangeVideoOwnershipExist (idArg: number | string, res: express.Response) {
const id = parseInt(idArg + '', 10)
const videoChangeOwnership = await VideoChangeOwnershipModel.load(id)
if (!videoChangeOwnership) {
res.fail({
status: HttpStatusCode.NOT_FOUND_404,
message: 'Video change ownership not found'
})
return false
}
res.locals.videoChangeOwnership = videoChangeOwnership
return true
}
export {
doesChangeVideoOwnershipExist
}