1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 18:29:27 +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

@ -9,6 +9,8 @@ import {
import { httpRequestJobScheduler } from '../jobs'
import { signObject, activityPubContextify } from '../../helpers'
import { Activity } from '../../../shared'
import { VideoAbuseInstance } from '../../models/video/video-abuse-interface'
import { getActivityPubUrl } from '../../helpers/activitypub'
async function sendCreateVideoChannel (videoChannel: VideoChannelInstance, t: Sequelize.Transaction) {
const videoChannelObject = videoChannel.toActivityPubObject()
@ -56,16 +58,28 @@ async function sendDeleteAccount (account: AccountInstance, t: Sequelize.Transac
return broadcastToFollowers(data, account, t)
}
async function sendVideoAbuse (
fromAccount: AccountInstance,
videoAbuse: VideoAbuseInstance,
video: VideoInstance,
t: Sequelize.Transaction
) {
const url = getActivityPubUrl('videoAbuse', videoAbuse.id.toString())
const data = await createActivityData(url, fromAccount, video.url)
return unicastTo(data, video.VideoChannel.Account.sharedInboxUrl, t)
}
async function sendAccept (fromAccount: AccountInstance, toAccount: AccountInstance, t: Sequelize.Transaction) {
const data = await acceptActivityData(fromAccount)
return unicastTo(data, toAccount, t)
return unicastTo(data, toAccount.inboxUrl, t)
}
async function sendFollow (fromAccount: AccountInstance, toAccount: AccountInstance, t: Sequelize.Transaction) {
const data = await followActivityData(toAccount.url, fromAccount)
return unicastTo(data, toAccount, t)
return unicastTo(data, toAccount.inboxUrl, t)
}
// ---------------------------------------------------------------------------
@ -79,7 +93,8 @@ export {
sendDeleteVideo,
sendDeleteAccount,
sendAccept,
sendFollow
sendFollow,
sendVideoAbuse
}
// ---------------------------------------------------------------------------
@ -95,9 +110,9 @@ async function broadcastToFollowers (data: any, fromAccount: AccountInstance, t:
return httpRequestJobScheduler.createJob(t, 'httpRequestBroadcastHandler', jobPayload)
}
async function unicastTo (data: any, toAccount: AccountInstance, t: Sequelize.Transaction) {
async function unicastTo (data: any, toAccountUrl: string, t: Sequelize.Transaction) {
const jobPayload = {
uris: [ toAccount.inboxUrl ],
uris: [ toAccountUrl ],
body: data
}