]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/videos/abuse.ts
Add ability to subscribe from the channel account page
[github/Chocobozzz/PeerTube.git] / server / controllers / api / videos / abuse.ts
index fe0a95cd51780eeacfe7c268896a7a3f77a8d636..ca70230a2f475eb05e7a7f40c9821a62fdf15b12 100644 (file)
@@ -3,7 +3,6 @@ import { UserRight, VideoAbuseCreate, VideoAbuseState } from '../../../../shared
 import { logger } from '../../../helpers/logger'
 import { getFormattedObjects } from '../../../helpers/utils'
 import { sequelizeTypescript } from '../../../initializers'
-import { sendVideoAbuse } from '../../../lib/activitypub/send'
 import {
   asyncMiddleware,
   asyncRetryTransactionMiddleware,
@@ -18,11 +17,10 @@ import {
   videoAbuseUpdateValidator
 } from '../../../middlewares'
 import { AccountModel } from '../../../models/account/account'
-import { VideoModel } from '../../../models/video/video'
 import { VideoAbuseModel } from '../../../models/video/video-abuse'
 import { auditLoggerFactory, VideoAbuseAuditView } from '../../../helpers/audit-logger'
-import { UserModel } from '../../../models/account/user'
 import { Notifier } from '../../../lib/notifier'
+import { sendVideoAbuse } from '../../../lib/activitypub/send/send-flag'
 
 const auditLogger = auditLoggerFactory('abuse')
 const abuseVideoRouter = express.Router()
@@ -69,7 +67,7 @@ async function listVideoAbuses (req: express.Request, res: express.Response) {
 }
 
 async function updateVideoAbuse (req: express.Request, res: express.Response) {
-  const videoAbuse: VideoAbuseModel = res.locals.videoAbuse
+  const videoAbuse = res.locals.videoAbuse
 
   if (req.body.moderationComment !== undefined) videoAbuse.moderationComment = req.body.moderationComment
   if (req.body.state !== undefined) videoAbuse.state = req.body.state
@@ -84,7 +82,7 @@ async function updateVideoAbuse (req: express.Request, res: express.Response) {
 }
 
 async function deleteVideoAbuse (req: express.Request, res: express.Response) {
-  const videoAbuse: VideoAbuseModel = res.locals.videoAbuse
+  const videoAbuse = res.locals.videoAbuse
 
   await sequelizeTypescript.transaction(t => {
     return videoAbuse.destroy({ transaction: t })
@@ -96,11 +94,11 @@ async function deleteVideoAbuse (req: express.Request, res: express.Response) {
 }
 
 async function reportVideoAbuse (req: express.Request, res: express.Response) {
-  const videoInstance = res.locals.video as VideoModel
+  const videoInstance = res.locals.video
   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 reporterAccount = await AccountModel.load(res.locals.oauth.token.User.Account.id, t)
 
     const abuseToCreate = {
       reporterAccountId: reporterAccount.id,