diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/index.ts | 1 | ||||
-rw-r--r-- | server/lib/activitypub/misc.ts | 6 | ||||
-rw-r--r-- | server/lib/activitypub/process-flag.ts | 2 | ||||
-rw-r--r-- | server/lib/activitypub/send-request.ts | 31 |
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 @@ | |||
1 | export * from './process-create' | 1 | export * from './process-create' |
2 | export * from './process-flag' | 2 | export * from './process-flag' |
3 | export * from './process-update' | 3 | export * from './process-update' |
4 | export * 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 | |||
8 | import { VideoFileAttributes } from '../../models/video/video-file-interface' | 8 | import { VideoFileAttributes } from '../../models/video/video-file-interface' |
9 | import { VideoAttributes, VideoInstance } from '../../models/video/video-interface' | 9 | import { VideoAttributes, VideoInstance } from '../../models/video/video-interface' |
10 | 10 | ||
11 | async function videoActivityObjectToDBAttributes (videoChannel: VideoChannelInstance, videoObject: VideoTorrentObject, t: Sequelize.Transaction) { | 11 | async 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 | ||
7 | function processFlagActivity (activity: ActivityCreate) { | 7 | function 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 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | ||
3 | import { database as db } from '../../initializers' | ||
3 | import { | 4 | import { |
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 | ||
19 | function sendUpdateVideoChannel (videoChannel: VideoChannelInstance, t: Sequelize.Transaction) { | 20 | function 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 | ||
26 | function sendDeleteVideoChannel (videoChannel: VideoChannelInstance, t: Sequelize.Transaction) { | 27 | function 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 | ||
33 | function sendAddVideo (video: VideoInstance, t: Sequelize.Transaction) { | 34 | function 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 | ||
40 | function sendUpdateVideo (video: VideoInstance, t: Sequelize.Transaction) { | 41 | function 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 | ||
47 | function sendDeleteVideo (video: VideoInstance, t: Sequelize.Transaction) { | 48 | function 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 | ||
56 | export { | 57 | export { |
57 | 58 | sendCreateVideoChannel, | |
59 | sendUpdateVideoChannel, | ||
60 | sendDeleteVideoChannel, | ||
61 | sendAddVideo, | ||
62 | sendUpdateVideo, | ||
63 | sendDeleteVideo | ||
58 | } | 64 | } |
59 | 65 | ||
60 | // --------------------------------------------------------------------------- | 66 | // --------------------------------------------------------------------------- |
61 | 67 | ||
62 | function broadcastToFollowers (data: any, t: Sequelize.Transaction) { | 68 | async 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 | ||
66 | function buildSignedActivity (byAccount: AccountInstance, data: Object) { | 79 | function buildSignedActivity (byAccount: AccountInstance, data: Object) { |