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/lib/activitypub/send-request.ts | |
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/lib/activitypub/send-request.ts')
-rw-r--r-- | server/lib/activitypub/send-request.ts | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/server/lib/activitypub/send-request.ts b/server/lib/activitypub/send-request.ts index f942a2eba..1a6cebc03 100644 --- a/server/lib/activitypub/send-request.ts +++ b/server/lib/activitypub/send-request.ts | |||
@@ -9,6 +9,8 @@ import { | |||
9 | import { httpRequestJobScheduler } from '../jobs' | 9 | import { httpRequestJobScheduler } from '../jobs' |
10 | import { signObject, activityPubContextify } from '../../helpers' | 10 | import { signObject, activityPubContextify } from '../../helpers' |
11 | import { Activity } from '../../../shared' | 11 | import { Activity } from '../../../shared' |
12 | import { VideoAbuseInstance } from '../../models/video/video-abuse-interface' | ||
13 | import { getActivityPubUrl } from '../../helpers/activitypub' | ||
12 | 14 | ||
13 | async function sendCreateVideoChannel (videoChannel: VideoChannelInstance, t: Sequelize.Transaction) { | 15 | async function sendCreateVideoChannel (videoChannel: VideoChannelInstance, t: Sequelize.Transaction) { |
14 | const videoChannelObject = videoChannel.toActivityPubObject() | 16 | const videoChannelObject = videoChannel.toActivityPubObject() |
@@ -56,16 +58,28 @@ async function sendDeleteAccount (account: AccountInstance, t: Sequelize.Transac | |||
56 | return broadcastToFollowers(data, account, t) | 58 | return broadcastToFollowers(data, account, t) |
57 | } | 59 | } |
58 | 60 | ||
61 | async function sendVideoAbuse ( | ||
62 | fromAccount: AccountInstance, | ||
63 | videoAbuse: VideoAbuseInstance, | ||
64 | video: VideoInstance, | ||
65 | t: Sequelize.Transaction | ||
66 | ) { | ||
67 | const url = getActivityPubUrl('videoAbuse', videoAbuse.id.toString()) | ||
68 | const data = await createActivityData(url, fromAccount, video.url) | ||
69 | |||
70 | return unicastTo(data, video.VideoChannel.Account.sharedInboxUrl, t) | ||
71 | } | ||
72 | |||
59 | async function sendAccept (fromAccount: AccountInstance, toAccount: AccountInstance, t: Sequelize.Transaction) { | 73 | async function sendAccept (fromAccount: AccountInstance, toAccount: AccountInstance, t: Sequelize.Transaction) { |
60 | const data = await acceptActivityData(fromAccount) | 74 | const data = await acceptActivityData(fromAccount) |
61 | 75 | ||
62 | return unicastTo(data, toAccount, t) | 76 | return unicastTo(data, toAccount.inboxUrl, t) |
63 | } | 77 | } |
64 | 78 | ||
65 | async function sendFollow (fromAccount: AccountInstance, toAccount: AccountInstance, t: Sequelize.Transaction) { | 79 | async function sendFollow (fromAccount: AccountInstance, toAccount: AccountInstance, t: Sequelize.Transaction) { |
66 | const data = await followActivityData(toAccount.url, fromAccount) | 80 | const data = await followActivityData(toAccount.url, fromAccount) |
67 | 81 | ||
68 | return unicastTo(data, toAccount, t) | 82 | return unicastTo(data, toAccount.inboxUrl, t) |
69 | } | 83 | } |
70 | 84 | ||
71 | // --------------------------------------------------------------------------- | 85 | // --------------------------------------------------------------------------- |
@@ -79,7 +93,8 @@ export { | |||
79 | sendDeleteVideo, | 93 | sendDeleteVideo, |
80 | sendDeleteAccount, | 94 | sendDeleteAccount, |
81 | sendAccept, | 95 | sendAccept, |
82 | sendFollow | 96 | sendFollow, |
97 | sendVideoAbuse | ||
83 | } | 98 | } |
84 | 99 | ||
85 | // --------------------------------------------------------------------------- | 100 | // --------------------------------------------------------------------------- |
@@ -95,9 +110,9 @@ async function broadcastToFollowers (data: any, fromAccount: AccountInstance, t: | |||
95 | return httpRequestJobScheduler.createJob(t, 'httpRequestBroadcastHandler', jobPayload) | 110 | return httpRequestJobScheduler.createJob(t, 'httpRequestBroadcastHandler', jobPayload) |
96 | } | 111 | } |
97 | 112 | ||
98 | async function unicastTo (data: any, toAccount: AccountInstance, t: Sequelize.Transaction) { | 113 | async function unicastTo (data: any, toAccountUrl: string, t: Sequelize.Transaction) { |
99 | const jobPayload = { | 114 | const jobPayload = { |
100 | uris: [ toAccount.inboxUrl ], | 115 | uris: [ toAccountUrl ], |
101 | body: data | 116 | body: data |
102 | } | 117 | } |
103 | 118 | ||