diff options
Diffstat (limited to 'server/lib/activitypub/send/misc.ts')
-rw-r--r-- | server/lib/activitypub/send/misc.ts | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/server/lib/activitypub/send/misc.ts b/server/lib/activitypub/send/misc.ts index dc0d3de57..7a21f0c94 100644 --- a/server/lib/activitypub/send/misc.ts +++ b/server/lib/activitypub/send/misc.ts | |||
@@ -7,7 +7,7 @@ import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | |||
7 | import { VideoModel } from '../../../models/video/video' | 7 | import { VideoModel } from '../../../models/video/video' |
8 | import { VideoCommentModel } from '../../../models/video/video-comment' | 8 | import { VideoCommentModel } from '../../../models/video/video-comment' |
9 | import { VideoShareModel } from '../../../models/video/video-share' | 9 | import { VideoShareModel } from '../../../models/video/video-share' |
10 | import { activitypubHttpJobScheduler, ActivityPubHttpPayload } from '../../jobs/activitypub-http-job-scheduler' | 10 | import { JobQueue } from '../../job-queue' |
11 | 11 | ||
12 | async function forwardActivity ( | 12 | async function forwardActivity ( |
13 | activity: Activity, | 13 | activity: Activity, |
@@ -35,12 +35,11 @@ async function forwardActivity ( | |||
35 | 35 | ||
36 | logger.debug('Creating forwarding job.', { uris }) | 36 | logger.debug('Creating forwarding job.', { uris }) |
37 | 37 | ||
38 | const jobPayload: ActivityPubHttpPayload = { | 38 | const payload = { |
39 | uris, | 39 | uris, |
40 | body: activity | 40 | body: activity |
41 | } | 41 | } |
42 | 42 | return JobQueue.Instance.createJob({ type: 'activitypub-http-broadcast', payload }) | |
43 | return activitypubHttpJobScheduler.createJob(t, 'activitypubHttpBroadcastHandler', jobPayload) | ||
44 | } | 43 | } |
45 | 44 | ||
46 | async function broadcastToFollowers ( | 45 | async function broadcastToFollowers ( |
@@ -51,44 +50,43 @@ async function broadcastToFollowers ( | |||
51 | actorsException: ActorModel[] = [] | 50 | actorsException: ActorModel[] = [] |
52 | ) { | 51 | ) { |
53 | const uris = await computeFollowerUris(toActorFollowers, actorsException, t) | 52 | const uris = await computeFollowerUris(toActorFollowers, actorsException, t) |
54 | return broadcastTo(uris, data, byActor, t) | 53 | return broadcastTo(uris, data, byActor) |
55 | } | 54 | } |
56 | 55 | ||
57 | async function broadcastToActors ( | 56 | async function broadcastToActors ( |
58 | data: any, | 57 | data: any, |
59 | byActor: ActorModel, | 58 | byActor: ActorModel, |
60 | toActors: ActorModel[], | 59 | toActors: ActorModel[], |
61 | t: Transaction, | ||
62 | actorsException: ActorModel[] = [] | 60 | actorsException: ActorModel[] = [] |
63 | ) { | 61 | ) { |
64 | const uris = await computeUris(toActors, actorsException) | 62 | const uris = await computeUris(toActors, actorsException) |
65 | return broadcastTo(uris, data, byActor, t) | 63 | return broadcastTo(uris, data, byActor) |
66 | } | 64 | } |
67 | 65 | ||
68 | async function broadcastTo (uris: string[], data: any, byActor: ActorModel, t: Transaction) { | 66 | async function broadcastTo (uris: string[], data: any, byActor: ActorModel) { |
69 | if (uris.length === 0) return undefined | 67 | if (uris.length === 0) return undefined |
70 | 68 | ||
71 | logger.debug('Creating broadcast job.', { uris }) | 69 | logger.debug('Creating broadcast job.', { uris }) |
72 | 70 | ||
73 | const jobPayload: ActivityPubHttpPayload = { | 71 | const payload = { |
74 | uris, | 72 | uris, |
75 | signatureActorId: byActor.id, | 73 | signatureActorId: byActor.id, |
76 | body: data | 74 | body: data |
77 | } | 75 | } |
78 | 76 | ||
79 | return activitypubHttpJobScheduler.createJob(t, 'activitypubHttpBroadcastHandler', jobPayload) | 77 | return JobQueue.Instance.createJob({ type: 'activitypub-http-broadcast', payload }) |
80 | } | 78 | } |
81 | 79 | ||
82 | async function unicastTo (data: any, byActor: ActorModel, toActorUrl: string, t: Transaction) { | 80 | async function unicastTo (data: any, byActor: ActorModel, toActorUrl: string) { |
83 | logger.debug('Creating unicast job.', { uri: toActorUrl }) | 81 | logger.debug('Creating unicast job.', { uri: toActorUrl }) |
84 | 82 | ||
85 | const jobPayload: ActivityPubHttpPayload = { | 83 | const payload = { |
86 | uris: [ toActorUrl ], | 84 | uri: toActorUrl, |
87 | signatureActorId: byActor.id, | 85 | signatureActorId: byActor.id, |
88 | body: data | 86 | body: data |
89 | } | 87 | } |
90 | 88 | ||
91 | return activitypubHttpJobScheduler.createJob(t, 'activitypubHttpUnicastHandler', jobPayload) | 89 | return JobQueue.Instance.createJob({ type: 'activitypub-http-unicast', payload }) |
92 | } | 90 | } |
93 | 91 | ||
94 | function getOriginVideoAudience (video: VideoModel, actorsInvolvedInVideo: ActorModel[]) { | 92 | function getOriginVideoAudience (video: VideoModel, actorsInvolvedInVideo: ActorModel[]) { |