aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r--server/controllers/api/videos/abuse.ts22
1 files changed, 8 insertions, 14 deletions
diff --git a/server/controllers/api/videos/abuse.ts b/server/controllers/api/videos/abuse.ts
index 29f901f60..d9b4e8772 100644
--- a/server/controllers/api/videos/abuse.ts
+++ b/server/controllers/api/videos/abuse.ts
@@ -18,6 +18,7 @@ import {
18} from '../../../middlewares' 18} from '../../../middlewares'
19import { VideoInstance } from '../../../models' 19import { VideoInstance } from '../../../models'
20import { VideoAbuseCreate, UserRight } from '../../../../shared' 20import { VideoAbuseCreate, UserRight } from '../../../../shared'
21import { sendVideoAbuse } from '../../../lib/index'
21 22
22const abuseVideoRouter = express.Router() 23const abuseVideoRouter = express.Router()
23 24
@@ -63,28 +64,21 @@ async function reportVideoAbuseRetryWrapper (req: express.Request, res: express.
63 64
64async function reportVideoAbuse (req: express.Request, res: express.Response) { 65async function reportVideoAbuse (req: express.Request, res: express.Response) {
65 const videoInstance = res.locals.video as VideoInstance 66 const videoInstance = res.locals.video as VideoInstance
66 const reporterUsername = res.locals.oauth.token.User.username 67 const reporterAccount = res.locals.oauth.token.User.Account
67 const body: VideoAbuseCreate = req.body 68 const body: VideoAbuseCreate = req.body
68 69
69 const abuseToCreate = { 70 const abuseToCreate = {
70 reporterUsername, 71 reporterAccountId: reporterAccount.id,
71 reason: body.reason, 72 reason: body.reason,
72 videoId: videoInstance.id, 73 videoId: videoInstance.id
73 reporterServerId: null // This is our server that reported this abuse
74 } 74 }
75 75
76 await db.sequelize.transaction(async t => { 76 await db.sequelize.transaction(async t => {
77 const abuse = await db.VideoAbuse.create(abuseToCreate, { transaction: t }) 77 const videoAbuseInstance = await db.VideoAbuse.create(abuseToCreate, { transaction: t })
78 // We send the information to the destination server 78
79 // We send the video abuse to the origin server
79 if (videoInstance.isOwned() === false) { 80 if (videoInstance.isOwned() === false) {
80 const reportData = { 81 await sendVideoAbuse(reporterAccount, videoAbuseInstance, videoInstance, t)
81 reporterUsername,
82 reportReason: abuse.reason,
83 videoUUID: videoInstance.uuid
84 }
85
86 // await friends.reportAbuseVideoToFriend(reportData, videoInstance, t)
87 // TODO: send abuse to origin server
88 } 82 }
89 }) 83 })
90 84