aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/actor.ts59
-rw-r--r--server/lib/activitypub/fetch.ts9
-rw-r--r--server/lib/activitypub/process/process-accept.ts2
-rw-r--r--server/lib/activitypub/process/process-follow.ts2
-rw-r--r--server/lib/activitypub/send/misc.ts26
-rw-r--r--server/lib/activitypub/send/send-accept.ts5
-rw-r--r--server/lib/activitypub/send/send-announce.ts2
-rw-r--r--server/lib/activitypub/send/send-create.ts22
-rw-r--r--server/lib/activitypub/send/send-follow.ts5
-rw-r--r--server/lib/activitypub/send/send-like.ts2
-rw-r--r--server/lib/activitypub/send/send-undo.ts14
11 files changed, 76 insertions, 72 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index c708b38ba..712de7d0d 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -64,7 +64,11 @@ async function getOrCreateActorAndServerAndModel (actorUrl: string, recurseIfNee
64 actor = await retryTransactionWrapper(saveActorAndServerAndModelIfNotExist, options) 64 actor = await retryTransactionWrapper(saveActorAndServerAndModelIfNotExist, options)
65 } 65 }
66 66
67 return refreshActorIfNeeded(actor) 67 const options = {
68 arguments: [ actor ],
69 errorMessage: 'Cannot refresh actor if needed with many retries.'
70 }
71 return retryTransactionWrapper(refreshActorIfNeeded, options)
68} 72}
69 73
70function buildActorInstance (type: ActivityPubActorType, url: string, preferredUsername: string, uuid?: string) { 74function buildActorInstance (type: ActivityPubActorType, url: string, preferredUsername: string, uuid?: string) {
@@ -325,38 +329,43 @@ async function saveVideoChannel (actor: ActorModel, result: FetchRemoteActorResu
325async function refreshActorIfNeeded (actor: ActorModel) { 329async function refreshActorIfNeeded (actor: ActorModel) {
326 if (!actor.isOutdated()) return actor 330 if (!actor.isOutdated()) return actor
327 331
328 const actorUrl = await getUrlFromWebfinger(actor.preferredUsername, actor.getHost()) 332 try {
329 const result = await fetchRemoteActor(actorUrl) 333 const actorUrl = await getUrlFromWebfinger(actor.preferredUsername, actor.getHost())
330 if (result === undefined) { 334 const result = await fetchRemoteActor(actorUrl)
331 logger.warn('Cannot fetch remote actor in refresh actor.') 335 if (result === undefined) {
332 return actor 336 logger.warn('Cannot fetch remote actor in refresh actor.')
333 } 337 return actor
334
335 return sequelizeTypescript.transaction(async t => {
336 updateInstanceWithAnother(actor, result.actor)
337
338 if (result.avatarName !== undefined) {
339 await updateActorAvatarInstance(actor, result.avatarName, t)
340 } 338 }
341 339
342 // Force update 340 return sequelizeTypescript.transaction(async t => {
343 actor.setDataValue('updatedAt', new Date()) 341 updateInstanceWithAnother(actor, result.actor)
344 await actor.save({ transaction: t })
345 342
346 if (actor.Account) { 343 if (result.avatarName !== undefined) {
347 await actor.save({ transaction: t }) 344 await updateActorAvatarInstance(actor, result.avatarName, t)
345 }
348 346
349 actor.Account.set('name', result.name) 347 // Force update
350 await actor.Account.save({ transaction: t }) 348 actor.setDataValue('updatedAt', new Date())
351 } else if (actor.VideoChannel) {
352 await actor.save({ transaction: t }) 349 await actor.save({ transaction: t })
353 350
354 actor.VideoChannel.set('name', result.name) 351 if (actor.Account) {
355 await actor.VideoChannel.save({ transaction: t }) 352 await actor.save({ transaction: t })
356 } 353
354 actor.Account.set('name', result.name)
355 await actor.Account.save({ transaction: t })
356 } else if (actor.VideoChannel) {
357 await actor.save({ transaction: t })
358
359 actor.VideoChannel.set('name', result.name)
360 await actor.VideoChannel.save({ transaction: t })
361 }
357 362
363 return actor
364 })
365 } catch (err) {
366 logger.warn('Cannot refresh actor.', err)
358 return actor 367 return actor
359 }) 368 }
360} 369}
361 370
362function normalizeActor (actor: any) { 371function normalizeActor (actor: any) {
diff --git a/server/lib/activitypub/fetch.ts b/server/lib/activitypub/fetch.ts
index 4fc97cc38..b1b370a1a 100644
--- a/server/lib/activitypub/fetch.ts
+++ b/server/lib/activitypub/fetch.ts
@@ -1,13 +1,12 @@
1import { Transaction } from 'sequelize'
2import { ActorModel } from '../../models/activitypub/actor' 1import { ActorModel } from '../../models/activitypub/actor'
3import { activitypubHttpJobScheduler, ActivityPubHttpPayload } from '../jobs/activitypub-http-job-scheduler' 2import { JobQueue } from '../job-queue'
4 3
5async function addFetchOutboxJob (actor: ActorModel, t: Transaction) { 4async function addFetchOutboxJob (actor: ActorModel) {
6 const jobPayload: ActivityPubHttpPayload = { 5 const payload = {
7 uris: [ actor.outboxUrl ] 6 uris: [ actor.outboxUrl ]
8 } 7 }
9 8
10 return activitypubHttpJobScheduler.createJob(t, 'activitypubHttpFetcherHandler', jobPayload) 9 return JobQueue.Instance.createJob({ type: 'activitypub-http-fetcher', payload })
11} 10}
12 11
13export { 12export {
diff --git a/server/lib/activitypub/process/process-accept.ts b/server/lib/activitypub/process/process-accept.ts
index 551f09ea7..7db2f8ff0 100644
--- a/server/lib/activitypub/process/process-accept.ts
+++ b/server/lib/activitypub/process/process-accept.ts
@@ -26,6 +26,6 @@ async function processAccept (actor: ActorModel, targetActor: ActorModel) {
26 if (follow.state !== 'accepted') { 26 if (follow.state !== 'accepted') {
27 follow.set('state', 'accepted') 27 follow.set('state', 'accepted')
28 await follow.save() 28 await follow.save()
29 await addFetchOutboxJob(targetActor, undefined) 29 await addFetchOutboxJob(targetActor)
30 } 30 }
31} 31}
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts
index 69f5c51b5..dc1d542b5 100644
--- a/server/lib/activitypub/process/process-follow.ts
+++ b/server/lib/activitypub/process/process-follow.ts
@@ -63,7 +63,7 @@ async function follow (actor: ActorModel, targetActorURL: string) {
63 actorFollow.ActorFollowing = targetActor 63 actorFollow.ActorFollowing = targetActor
64 64
65 // Target sends to actor he accepted the follow request 65 // Target sends to actor he accepted the follow request
66 return sendAccept(actorFollow, t) 66 return sendAccept(actorFollow)
67 }) 67 })
68 68
69 logger.info('Actor %s is followed by actor %s.', targetActorURL, actor.url) 69 logger.info('Actor %s is followed by actor %s.', targetActorURL, actor.url)
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'
7import { VideoModel } from '../../../models/video/video' 7import { VideoModel } from '../../../models/video/video'
8import { VideoCommentModel } from '../../../models/video/video-comment' 8import { VideoCommentModel } from '../../../models/video/video-comment'
9import { VideoShareModel } from '../../../models/video/video-share' 9import { VideoShareModel } from '../../../models/video/video-share'
10import { activitypubHttpJobScheduler, ActivityPubHttpPayload } from '../../jobs/activitypub-http-job-scheduler' 10import { JobQueue } from '../../job-queue'
11 11
12async function forwardActivity ( 12async 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
46async function broadcastToFollowers ( 45async 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
57async function broadcastToActors ( 56async 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
68async function broadcastTo (uris: string[], data: any, byActor: ActorModel, t: Transaction) { 66async 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
82async function unicastTo (data: any, byActor: ActorModel, toActorUrl: string, t: Transaction) { 80async 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
94function getOriginVideoAudience (video: VideoModel, actorsInvolvedInVideo: ActorModel[]) { 92function getOriginVideoAudience (video: VideoModel, actorsInvolvedInVideo: ActorModel[]) {
diff --git a/server/lib/activitypub/send/send-accept.ts b/server/lib/activitypub/send/send-accept.ts
index 4eaa329d9..064fd88d2 100644
--- a/server/lib/activitypub/send/send-accept.ts
+++ b/server/lib/activitypub/send/send-accept.ts
@@ -1,4 +1,3 @@
1import { Transaction } from 'sequelize'
2import { ActivityAccept, ActivityFollow } from '../../../../shared/models/activitypub' 1import { ActivityAccept, ActivityFollow } from '../../../../shared/models/activitypub'
3import { ActorModel } from '../../../models/activitypub/actor' 2import { ActorModel } from '../../../models/activitypub/actor'
4import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 3import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
@@ -6,7 +5,7 @@ import { getActorFollowAcceptActivityPubUrl, getActorFollowActivityPubUrl } from
6import { unicastTo } from './misc' 5import { unicastTo } from './misc'
7import { followActivityData } from './send-follow' 6import { followActivityData } from './send-follow'
8 7
9async function sendAccept (actorFollow: ActorFollowModel, t: Transaction) { 8async function sendAccept (actorFollow: ActorFollowModel) {
10 const follower = actorFollow.ActorFollower 9 const follower = actorFollow.ActorFollower
11 const me = actorFollow.ActorFollowing 10 const me = actorFollow.ActorFollowing
12 11
@@ -16,7 +15,7 @@ async function sendAccept (actorFollow: ActorFollowModel, t: Transaction) {
16 const url = getActorFollowAcceptActivityPubUrl(actorFollow) 15 const url = getActorFollowAcceptActivityPubUrl(actorFollow)
17 const data = acceptActivityData(url, me, followData) 16 const data = acceptActivityData(url, me, followData)
18 17
19 return unicastTo(data, me, follower.inboxUrl, t) 18 return unicastTo(data, me, follower.inboxUrl)
20} 19}
21 20
22// --------------------------------------------------------------------------- 21// ---------------------------------------------------------------------------
diff --git a/server/lib/activitypub/send/send-announce.ts b/server/lib/activitypub/send/send-announce.ts
index 578fbc630..93b5668d2 100644
--- a/server/lib/activitypub/send/send-announce.ts
+++ b/server/lib/activitypub/send/send-announce.ts
@@ -42,7 +42,7 @@ async function sendVideoAnnounceToOrigin (byActor: ActorModel, video: VideoModel
42 const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) 42 const audience = getOriginVideoAudience(video, actorsInvolvedInVideo)
43 const data = await createActivityData(url, byActor, announcedActivity, t, audience) 43 const data = await createActivityData(url, byActor, announcedActivity, t, audience)
44 44
45 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl, t) 45 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl)
46} 46}
47 47
48async function announceActivityData ( 48async function announceActivityData (
diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts
index 9db663be1..b92615e9b 100644
--- a/server/lib/activitypub/send/send-create.ts
+++ b/server/lib/activitypub/send/send-create.ts
@@ -8,8 +8,14 @@ import { VideoAbuseModel } from '../../../models/video/video-abuse'
8import { VideoCommentModel } from '../../../models/video/video-comment' 8import { VideoCommentModel } from '../../../models/video/video-comment'
9import { getVideoAbuseActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoViewActivityPubUrl } from '../url' 9import { getVideoAbuseActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoViewActivityPubUrl } from '../url'
10import { 10import {
11 audiencify, broadcastToActors, broadcastToFollowers, getActorsInvolvedInVideo, getAudience, getObjectFollowersAudience, 11 audiencify,
12 getOriginVideoAudience, getOriginVideoCommentAudience, 12 broadcastToActors,
13 broadcastToFollowers,
14 getActorsInvolvedInVideo,
15 getAudience,
16 getObjectFollowersAudience,
17 getOriginVideoAudience,
18 getOriginVideoCommentAudience,
13 unicastTo 19 unicastTo
14} from './misc' 20} from './misc'
15 21
@@ -31,7 +37,7 @@ async function sendVideoAbuse (byActor: ActorModel, videoAbuse: VideoAbuseModel,
31 const audience = { to: [ video.VideoChannel.Account.Actor.url ], cc: [] } 37 const audience = { to: [ video.VideoChannel.Account.Actor.url ], cc: [] }
32 const data = await createActivityData(url, byActor, videoAbuse.toActivityPubObject(), t, audience) 38 const data = await createActivityData(url, byActor, videoAbuse.toActivityPubObject(), t, audience)
33 39
34 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl, t) 40 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl)
35} 41}
36 42
37async function sendCreateVideoCommentToOrigin (comment: VideoCommentModel, t: Transaction) { 43async function sendCreateVideoCommentToOrigin (comment: VideoCommentModel, t: Transaction) {
@@ -47,13 +53,13 @@ async function sendCreateVideoCommentToOrigin (comment: VideoCommentModel, t: Tr
47 53
48 // This was a reply, send it to the parent actors 54 // This was a reply, send it to the parent actors
49 const actorsException = [ byActor ] 55 const actorsException = [ byActor ]
50 await broadcastToActors(data, byActor, threadParentComments.map(c => c.Account.Actor), t, actorsException) 56 await broadcastToActors(data, byActor, threadParentComments.map(c => c.Account.Actor), actorsException)
51 57
52 // Broadcast to our followers 58 // Broadcast to our followers
53 await broadcastToFollowers(data, byActor, [ byActor ], t) 59 await broadcastToFollowers(data, byActor, [ byActor ], t)
54 60
55 // Send to origin 61 // Send to origin
56 return unicastTo(data, byActor, comment.Video.VideoChannel.Account.Actor.sharedInboxUrl, t) 62 return unicastTo(data, byActor, comment.Video.VideoChannel.Account.Actor.sharedInboxUrl)
57} 63}
58 64
59async function sendCreateVideoCommentToVideoFollowers (comment: VideoCommentModel, t: Transaction) { 65async function sendCreateVideoCommentToVideoFollowers (comment: VideoCommentModel, t: Transaction) {
@@ -69,7 +75,7 @@ async function sendCreateVideoCommentToVideoFollowers (comment: VideoCommentMode
69 75
70 // This was a reply, send it to the parent actors 76 // This was a reply, send it to the parent actors
71 const actorsException = [ byActor ] 77 const actorsException = [ byActor ]
72 await broadcastToActors(data, byActor, threadParentComments.map(c => c.Account.Actor), t, actorsException) 78 await broadcastToActors(data, byActor, threadParentComments.map(c => c.Account.Actor), actorsException)
73 79
74 // Broadcast to our followers 80 // Broadcast to our followers
75 await broadcastToFollowers(data, byActor, [ byActor ], t) 81 await broadcastToFollowers(data, byActor, [ byActor ], t)
@@ -86,7 +92,7 @@ async function sendCreateViewToOrigin (byActor: ActorModel, video: VideoModel, t
86 const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) 92 const audience = getOriginVideoAudience(video, actorsInvolvedInVideo)
87 const data = await createActivityData(url, byActor, viewActivityData, t, audience) 93 const data = await createActivityData(url, byActor, viewActivityData, t, audience)
88 94
89 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl, t) 95 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl)
90} 96}
91 97
92async function sendCreateViewToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { 98async function sendCreateViewToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) {
@@ -111,7 +117,7 @@ async function sendCreateDislikeToOrigin (byActor: ActorModel, video: VideoModel
111 const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) 117 const audience = getOriginVideoAudience(video, actorsInvolvedInVideo)
112 const data = await createActivityData(url, byActor, dislikeActivityData, t, audience) 118 const data = await createActivityData(url, byActor, dislikeActivityData, t, audience)
113 119
114 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl, t) 120 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl)
115} 121}
116 122
117async function sendCreateDislikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { 123async function sendCreateDislikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) {
diff --git a/server/lib/activitypub/send/send-follow.ts b/server/lib/activitypub/send/send-follow.ts
index eac60e94f..4e9865af4 100644
--- a/server/lib/activitypub/send/send-follow.ts
+++ b/server/lib/activitypub/send/send-follow.ts
@@ -1,18 +1,17 @@
1import { Transaction } from 'sequelize'
2import { ActivityFollow } from '../../../../shared/models/activitypub' 1import { ActivityFollow } from '../../../../shared/models/activitypub'
3import { ActorModel } from '../../../models/activitypub/actor' 2import { ActorModel } from '../../../models/activitypub/actor'
4import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 3import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
5import { getActorFollowActivityPubUrl } from '../url' 4import { getActorFollowActivityPubUrl } from '../url'
6import { unicastTo } from './misc' 5import { unicastTo } from './misc'
7 6
8function sendFollow (actorFollow: ActorFollowModel, t: Transaction) { 7function sendFollow (actorFollow: ActorFollowModel) {
9 const me = actorFollow.ActorFollower 8 const me = actorFollow.ActorFollower
10 const following = actorFollow.ActorFollowing 9 const following = actorFollow.ActorFollowing
11 10
12 const url = getActorFollowActivityPubUrl(actorFollow) 11 const url = getActorFollowActivityPubUrl(actorFollow)
13 const data = followActivityData(url, me, following) 12 const data = followActivityData(url, me, following)
14 13
15 return unicastTo(data, me, following.inboxUrl, t) 14 return unicastTo(data, me, following.inboxUrl)
16} 15}
17 16
18function followActivityData (url: string, byActor: ActorModel, targetActor: ActorModel): ActivityFollow { 17function followActivityData (url: string, byActor: ActorModel, targetActor: ActorModel): ActivityFollow {
diff --git a/server/lib/activitypub/send/send-like.ts b/server/lib/activitypub/send/send-like.ts
index 743646455..78ed1aaf2 100644
--- a/server/lib/activitypub/send/send-like.ts
+++ b/server/lib/activitypub/send/send-like.ts
@@ -20,7 +20,7 @@ async function sendLikeToOrigin (byActor: ActorModel, video: VideoModel, t: Tran
20 const audience = getOriginVideoAudience(video, accountsInvolvedInVideo) 20 const audience = getOriginVideoAudience(video, accountsInvolvedInVideo)
21 const data = await likeActivityData(url, byActor, video, t, audience) 21 const data = await likeActivityData(url, byActor, video, t, audience)
22 22
23 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl, t) 23 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl)
24} 24}
25 25
26async function sendLikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { 26async function sendLikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) {
diff --git a/server/lib/activitypub/send/send-undo.ts b/server/lib/activitypub/send/send-undo.ts
index 3a0597fba..4a08b5ca1 100644
--- a/server/lib/activitypub/send/send-undo.ts
+++ b/server/lib/activitypub/send/send-undo.ts
@@ -1,11 +1,5 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { 2import { ActivityAudience, ActivityCreate, ActivityFollow, ActivityLike, ActivityUndo } from '../../../../shared/models/activitypub'
3 ActivityAudience,
4 ActivityCreate,
5 ActivityFollow,
6 ActivityLike,
7 ActivityUndo
8} from '../../../../shared/models/activitypub'
9import { ActorModel } from '../../../models/activitypub/actor' 3import { ActorModel } from '../../../models/activitypub/actor'
10import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 4import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
11import { VideoModel } from '../../../models/video/video' 5import { VideoModel } from '../../../models/video/video'
@@ -33,7 +27,7 @@ async function sendUndoFollow (actorFollow: ActorFollowModel, t: Transaction) {
33 const object = followActivityData(followUrl, me, following) 27 const object = followActivityData(followUrl, me, following)
34 const data = await undoActivityData(undoUrl, me, object, t) 28 const data = await undoActivityData(undoUrl, me, object, t)
35 29
36 return unicastTo(data, me, following.inboxUrl, t) 30 return unicastTo(data, me, following.inboxUrl)
37} 31}
38 32
39async function sendUndoLikeToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { 33async function sendUndoLikeToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) {
@@ -45,7 +39,7 @@ async function sendUndoLikeToOrigin (byActor: ActorModel, video: VideoModel, t:
45 const object = await likeActivityData(likeUrl, byActor, video, t) 39 const object = await likeActivityData(likeUrl, byActor, video, t)
46 const data = await undoActivityData(undoUrl, byActor, object, t, audience) 40 const data = await undoActivityData(undoUrl, byActor, object, t, audience)
47 41
48 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl, t) 42 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl)
49} 43}
50 44
51async function sendUndoLikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { 45async function sendUndoLikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) {
@@ -72,7 +66,7 @@ async function sendUndoDislikeToOrigin (byActor: ActorModel, video: VideoModel,
72 66
73 const data = await undoActivityData(undoUrl, byActor, object, t, audience) 67 const data = await undoActivityData(undoUrl, byActor, object, t, audience)
74 68
75 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl, t) 69 return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl)
76} 70}
77 71
78async function sendUndoDislikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { 72async function sendUndoDislikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) {