aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/index.ts1
-rw-r--r--server/lib/activitypub/misc.ts6
-rw-r--r--server/lib/activitypub/process-flag.ts2
-rw-r--r--server/lib/activitypub/send-request.ts31
4 files changed, 29 insertions, 11 deletions
diff --git a/server/lib/activitypub/index.ts b/server/lib/activitypub/index.ts
index 740800606..f8d56528a 100644
--- a/server/lib/activitypub/index.ts
+++ b/server/lib/activitypub/index.ts
@@ -1,3 +1,4 @@
1export * from './process-create' 1export * from './process-create'
2export * from './process-flag' 2export * from './process-flag'
3export * from './process-update' 3export * from './process-update'
4export * from './send-request'
diff --git a/server/lib/activitypub/misc.ts b/server/lib/activitypub/misc.ts
index 05e77ebc3..2cf0c4fd1 100644
--- a/server/lib/activitypub/misc.ts
+++ b/server/lib/activitypub/misc.ts
@@ -8,7 +8,11 @@ import { VideoChannelInstance } from '../../models/video/video-channel-interface
8import { VideoFileAttributes } from '../../models/video/video-file-interface' 8import { VideoFileAttributes } from '../../models/video/video-file-interface'
9import { VideoAttributes, VideoInstance } from '../../models/video/video-interface' 9import { VideoAttributes, VideoInstance } from '../../models/video/video-interface'
10 10
11async function videoActivityObjectToDBAttributes (videoChannel: VideoChannelInstance, videoObject: VideoTorrentObject, t: Sequelize.Transaction) { 11async function videoActivityObjectToDBAttributes (
12 videoChannel: VideoChannelInstance,
13 videoObject: VideoTorrentObject,
14 t: Sequelize.Transaction
15) {
12 const videoFromDatabase = await db.Video.loadByUUIDOrURL(videoObject.uuid, videoObject.id, t) 16 const videoFromDatabase = await db.Video.loadByUUIDOrURL(videoObject.uuid, videoObject.id, t)
13 if (videoFromDatabase) throw new Error('Video with this UUID/Url already exists.') 17 if (videoFromDatabase) throw new Error('Video with this UUID/Url already exists.')
14 18
diff --git a/server/lib/activitypub/process-flag.ts b/server/lib/activitypub/process-flag.ts
index 6fa862ee9..b562dce4d 100644
--- a/server/lib/activitypub/process-flag.ts
+++ b/server/lib/activitypub/process-flag.ts
@@ -5,7 +5,7 @@ import {
5} from '../../../shared' 5} from '../../../shared'
6 6
7function processFlagActivity (activity: ActivityCreate) { 7function processFlagActivity (activity: ActivityCreate) {
8 // empty 8 return Promise.resolve(undefined)
9} 9}
10 10
11// --------------------------------------------------------------------------- 11// ---------------------------------------------------------------------------
diff --git a/server/lib/activitypub/send-request.ts b/server/lib/activitypub/send-request.ts
index 6a31c226d..91101f5ad 100644
--- a/server/lib/activitypub/send-request.ts
+++ b/server/lib/activitypub/send-request.ts
@@ -1,5 +1,6 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2 2
3import { database as db } from '../../initializers'
3import { 4import {
4 AccountInstance, 5 AccountInstance,
5 VideoInstance, 6 VideoInstance,
@@ -13,54 +14,66 @@ function sendCreateVideoChannel (videoChannel: VideoChannelInstance, t: Sequeliz
13 const videoChannelObject = videoChannel.toActivityPubObject() 14 const videoChannelObject = videoChannel.toActivityPubObject()
14 const data = createActivityData(videoChannel.url, videoChannel.Account, videoChannelObject) 15 const data = createActivityData(videoChannel.url, videoChannel.Account, videoChannelObject)
15 16
16 return broadcastToFollowers(data, t) 17 return broadcastToFollowers(data, videoChannel.Account, t)
17} 18}
18 19
19function sendUpdateVideoChannel (videoChannel: VideoChannelInstance, t: Sequelize.Transaction) { 20function sendUpdateVideoChannel (videoChannel: VideoChannelInstance, t: Sequelize.Transaction) {
20 const videoChannelObject = videoChannel.toActivityPubObject() 21 const videoChannelObject = videoChannel.toActivityPubObject()
21 const data = updateActivityData(videoChannel.url, videoChannel.Account, videoChannelObject) 22 const data = updateActivityData(videoChannel.url, videoChannel.Account, videoChannelObject)
22 23
23 return broadcastToFollowers(data, t) 24 return broadcastToFollowers(data, videoChannel.Account, t)
24} 25}
25 26
26function sendDeleteVideoChannel (videoChannel: VideoChannelInstance, t: Sequelize.Transaction) { 27function sendDeleteVideoChannel (videoChannel: VideoChannelInstance, t: Sequelize.Transaction) {
27 const videoChannelObject = videoChannel.toActivityPubObject() 28 const videoChannelObject = videoChannel.toActivityPubObject()
28 const data = deleteActivityData(videoChannel.url, videoChannel.Account, videoChannelObject) 29 const data = deleteActivityData(videoChannel.url, videoChannel.Account, videoChannelObject)
29 30
30 return broadcastToFollowers(data, t) 31 return broadcastToFollowers(data, videoChannel.Account, t)
31} 32}
32 33
33function sendAddVideo (video: VideoInstance, t: Sequelize.Transaction) { 34function sendAddVideo (video: VideoInstance, t: Sequelize.Transaction) {
34 const videoObject = video.toActivityPubObject() 35 const videoObject = video.toActivityPubObject()
35 const data = addActivityData(video.url, video.VideoChannel.Account, video.VideoChannel.url, videoObject) 36 const data = addActivityData(video.url, video.VideoChannel.Account, video.VideoChannel.url, videoObject)
36 37
37 return broadcastToFollowers(data, t) 38 return broadcastToFollowers(data, video.VideoChannel.Account, t)
38} 39}
39 40
40function sendUpdateVideo (video: VideoInstance, t: Sequelize.Transaction) { 41function sendUpdateVideo (video: VideoInstance, t: Sequelize.Transaction) {
41 const videoObject = video.toActivityPubObject() 42 const videoObject = video.toActivityPubObject()
42 const data = updateActivityData(video.url, video.VideoChannel.Account, videoObject) 43 const data = updateActivityData(video.url, video.VideoChannel.Account, videoObject)
43 44
44 return broadcastToFollowers(data, t) 45 return broadcastToFollowers(data, video.VideoChannel.Account, t)
45} 46}
46 47
47function sendDeleteVideo (video: VideoInstance, t: Sequelize.Transaction) { 48function sendDeleteVideo (video: VideoInstance, t: Sequelize.Transaction) {
48 const videoObject = video.toActivityPubObject() 49 const videoObject = video.toActivityPubObject()
49 const data = deleteActivityData(video.url, video.VideoChannel.Account, videoObject) 50 const data = deleteActivityData(video.url, video.VideoChannel.Account, videoObject)
50 51
51 return broadcastToFollowers(data, t) 52 return broadcastToFollowers(data, video.VideoChannel.Account, t)
52} 53}
53 54
54// --------------------------------------------------------------------------- 55// ---------------------------------------------------------------------------
55 56
56export { 57export {
57 58 sendCreateVideoChannel,
59 sendUpdateVideoChannel,
60 sendDeleteVideoChannel,
61 sendAddVideo,
62 sendUpdateVideo,
63 sendDeleteVideo
58} 64}
59 65
60// --------------------------------------------------------------------------- 66// ---------------------------------------------------------------------------
61 67
62function broadcastToFollowers (data: any, t: Sequelize.Transaction) { 68async function broadcastToFollowers (data: any, fromAccount: AccountInstance, t: Sequelize.Transaction) {
63 return httpRequestJobScheduler.createJob(t, 'http-request', 'httpRequestBroadcastHandler', data) 69 const result = await db.Account.listFollowerUrlsForApi(fromAccount.name, 0)
70
71 const jobPayload = {
72 uris: result.data,
73 body: data
74 }
75
76 return httpRequestJobScheduler.createJob(t, 'httpRequestBroadcastHandler', jobPayload)
64} 77}
65 78
66function buildSignedActivity (byAccount: AccountInstance, data: Object) { 79function buildSignedActivity (byAccount: AccountInstance, data: Object) {