From 8e13fa7d09e9925b4559cbba6c5d72c5ff1bd391 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Nov 2017 15:12:23 +0100 Subject: Add video abuse to activity pub --- server/controllers/api/videos/abuse.ts | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'server/controllers/api/videos') 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 { } from '../../../middlewares' import { VideoInstance } from '../../../models' import { VideoAbuseCreate, UserRight } from '../../../../shared' +import { sendVideoAbuse } from '../../../lib/index' const abuseVideoRouter = express.Router() @@ -63,28 +64,21 @@ async function reportVideoAbuseRetryWrapper (req: express.Request, res: express. async function reportVideoAbuse (req: express.Request, res: express.Response) { const videoInstance = res.locals.video as VideoInstance - const reporterUsername = res.locals.oauth.token.User.username + const reporterAccount = res.locals.oauth.token.User.Account const body: VideoAbuseCreate = req.body const abuseToCreate = { - reporterUsername, + reporterAccountId: reporterAccount.id, reason: body.reason, - videoId: videoInstance.id, - reporterServerId: null // This is our server that reported this abuse + videoId: videoInstance.id } await db.sequelize.transaction(async t => { - const abuse = await db.VideoAbuse.create(abuseToCreate, { transaction: t }) - // We send the information to the destination server + const videoAbuseInstance = await db.VideoAbuse.create(abuseToCreate, { transaction: t }) + + // We send the video abuse to the origin server if (videoInstance.isOwned() === false) { - const reportData = { - reporterUsername, - reportReason: abuse.reason, - videoUUID: videoInstance.uuid - } - - // await friends.reportAbuseVideoToFriend(reportData, videoInstance, t) - // TODO: send abuse to origin server + await sendVideoAbuse(reporterAccount, videoAbuseInstance, videoInstance, t) } }) -- cgit v1.2.3