+
+ // Do not send the delete to other instances, we delete OUR copy of this video abuse
+
+ return res.type('json').status(204).end()
+}
+
+async function reportVideoAbuse (req: express.Request, res: express.Response) {
+ const videoInstance = res.locals.video as VideoModel
+ const body: VideoAbuseCreate = req.body
+
+ const videoAbuse: VideoAbuseModel = await sequelizeTypescript.transaction(async t => {
+ const reporterAccount = await AccountModel.load((res.locals.oauth.token.User as UserModel).Account.id, t)
+
+ const abuseToCreate = {
+ reporterAccountId: reporterAccount.id,
+ reason: body.reason,
+ videoId: videoInstance.id,
+ state: VideoAbuseState.PENDING
+ }
+
+ const videoAbuseInstance = await VideoAbuseModel.create(abuseToCreate, { transaction: t })
+ videoAbuseInstance.Video = videoInstance
+ videoAbuseInstance.Account = reporterAccount
+
+ // We send the video abuse to the origin server
+ if (videoInstance.isOwned() === false) {
+ await sendVideoAbuse(reporterAccount.Actor, videoAbuseInstance, videoInstance)
+ }
+
+ auditLogger.create(reporterAccount.Actor.getIdentifier(), new VideoAbuseAuditView(videoAbuseInstance.toFormattedJSON()))
+
+ return videoAbuseInstance