1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Add video abuse to activity pub

This commit is contained in:
Chocobozzz 2017-11-15 15:12:23 +01:00
parent 59c857da59
commit 8e13fa7d09
No known key found for this signature in database
GPG key ID: 583A612D890159BE
13 changed files with 114 additions and 68 deletions

View file

@ -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
if (videoInstance.isOwned() === false) {
const reportData = {
reporterUsername,
reportReason: abuse.reason,
videoUUID: videoInstance.uuid
}
const videoAbuseInstance = await db.VideoAbuse.create(abuseToCreate, { transaction: t })
// await friends.reportAbuseVideoToFriend(reportData, videoInstance, t)
// TODO: send abuse to origin server
// We send the video abuse to the origin server
if (videoInstance.isOwned() === false) {
await sendVideoAbuse(reporterAccount, videoAbuseInstance, videoInstance, t)
}
})