diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-15 15:12:23 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:52 +0100 |
commit | 8e13fa7d09e9925b4559cbba6c5d72c5ff1bd391 (patch) | |
tree | a59070f4dc6b52a5b422bd31a8eb8ea3bff831a0 /server/controllers/api/videos | |
parent | 59c857da5961e2bcddcfd07832783c1e4afcd01a (diff) | |
download | PeerTube-8e13fa7d09e9925b4559cbba6c5d72c5ff1bd391.tar.gz PeerTube-8e13fa7d09e9925b4559cbba6c5d72c5ff1bd391.tar.zst PeerTube-8e13fa7d09e9925b4559cbba6c5d72c5ff1bd391.zip |
Add video abuse to activity pub
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/abuse.ts | 22 |
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' |
19 | import { VideoInstance } from '../../../models' | 19 | import { VideoInstance } from '../../../models' |
20 | import { VideoAbuseCreate, UserRight } from '../../../../shared' | 20 | import { VideoAbuseCreate, UserRight } from '../../../../shared' |
21 | import { sendVideoAbuse } from '../../../lib/index' | ||
21 | 22 | ||
22 | const abuseVideoRouter = express.Router() | 23 | const abuseVideoRouter = express.Router() |
23 | 24 | ||
@@ -63,28 +64,21 @@ async function reportVideoAbuseRetryWrapper (req: express.Request, res: express. | |||
63 | 64 | ||
64 | async function reportVideoAbuse (req: express.Request, res: express.Response) { | 65 | async 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 | ||