- const videoInstance = res.locals.videoAll
- const body: VideoAbuseCreate = req.body
- let reporterAccount: MAccountDefault
- let videoAbuseJSON: VideoAbuse
-
- const videoAbuseInstance = await sequelizeTypescript.transaction(async t => {
- reporterAccount = await AccountModel.load(res.locals.oauth.token.User.Account.id, t)
- const predefinedReasons = body.predefinedReasons?.map(r => videoAbusePredefinedReasonsMap[r])
-
- const abuseToCreate = {
- reporterAccountId: reporterAccount.id,
- reason: body.reason,
- videoId: videoInstance.id,
- state: VideoAbuseState.PENDING,
- predefinedReasons,
- startAt: body.startAt,
- endAt: body.endAt
- }
-
- const videoAbuseInstance: MVideoAbuseAccountVideo = await VideoAbuseModel.create(abuseToCreate, { transaction: t })
- videoAbuseInstance.Video = videoInstance
- videoAbuseInstance.Account = reporterAccount