aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/process/process-announce.ts5
-rw-r--r--server/lib/activitypub/process/process-create.ts12
-rw-r--r--server/lib/activitypub/process/process-like.ts6
-rw-r--r--server/lib/activitypub/process/process-undo.ts18
-rw-r--r--server/lib/activitypub/send/utils.ts18
5 files changed, 42 insertions, 17 deletions
diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts
index a6e1e2d47..4e50da8d2 100644
--- a/server/lib/activitypub/process/process-announce.ts
+++ b/server/lib/activitypub/process/process-announce.ts
@@ -5,7 +5,7 @@ import { ActorModel } from '../../../models/activitypub/actor'
5import { VideoModel } from '../../../models/video/video' 5import { VideoModel } from '../../../models/video/video'
6import { VideoShareModel } from '../../../models/video/video-share' 6import { VideoShareModel } from '../../../models/video/video-share'
7import { getOrCreateActorAndServerAndModel } from '../actor' 7import { getOrCreateActorAndServerAndModel } from '../actor'
8import { forwardActivity } from '../send/utils' 8import { forwardVideoRelatedActivity } from '../send/utils'
9import { getOrCreateAccountAndVideoAndChannel } from '../videos' 9import { getOrCreateAccountAndVideoAndChannel } from '../videos'
10 10
11async function processAnnounceActivity (activity: ActivityAnnounce) { 11async function processAnnounceActivity (activity: ActivityAnnounce) {
@@ -58,7 +58,8 @@ async function shareVideo (actorAnnouncer: ActorModel, activity: ActivityAnnounc
58 if (video.isOwned() && created === true) { 58 if (video.isOwned() && created === true) {
59 // Don't resend the activity to the sender 59 // Don't resend the activity to the sender
60 const exceptions = [ actorAnnouncer ] 60 const exceptions = [ actorAnnouncer ]
61 await forwardActivity(activity, t, exceptions) 61
62 await forwardVideoRelatedActivity(activity, t, exceptions, video)
62 } 63 }
63 64
64 return undefined 65 return undefined
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts
index 99a5f6f9c..38dacf772 100644
--- a/server/lib/activitypub/process/process-create.ts
+++ b/server/lib/activitypub/process/process-create.ts
@@ -9,10 +9,9 @@ import { ActorModel } from '../../../models/activitypub/actor'
9import { VideoAbuseModel } from '../../../models/video/video-abuse' 9import { VideoAbuseModel } from '../../../models/video/video-abuse'
10import { VideoCommentModel } from '../../../models/video/video-comment' 10import { VideoCommentModel } from '../../../models/video/video-comment'
11import { getOrCreateActorAndServerAndModel } from '../actor' 11import { getOrCreateActorAndServerAndModel } from '../actor'
12import { getActorsInvolvedInVideo } from '../audience'
13import { resolveThread } from '../video-comments' 12import { resolveThread } from '../video-comments'
14import { getOrCreateAccountAndVideoAndChannel } from '../videos' 13import { getOrCreateAccountAndVideoAndChannel } from '../videos'
15import { forwardActivity } from '../send/utils' 14import { forwardActivity, forwardVideoRelatedActivity } from '../send/utils'
16 15
17async function processCreateActivity (activity: ActivityCreate) { 16async function processCreateActivity (activity: ActivityCreate) {
18 const activityObject = activity.object 17 const activityObject = activity.object
@@ -87,7 +86,8 @@ async function createVideoDislike (byActor: ActorModel, activity: ActivityCreate
87 if (video.isOwned() && created === true) { 86 if (video.isOwned() && created === true) {
88 // Don't resend the activity to the sender 87 // Don't resend the activity to the sender
89 const exceptions = [ byActor ] 88 const exceptions = [ byActor ]
90 await forwardActivity(activity, t, exceptions) 89
90 await forwardVideoRelatedActivity(activity, t, exceptions, video)
91 } 91 }
92 }) 92 })
93} 93}
@@ -190,11 +190,7 @@ async function createVideoComment (byActor: ActorModel, activity: ActivityCreate
190 // Don't resend the activity to the sender 190 // Don't resend the activity to the sender
191 const exceptions = [ byActor ] 191 const exceptions = [ byActor ]
192 192
193 // Mastodon does not add our announces in audience, so we forward to them manually 193 await forwardVideoRelatedActivity(activity, t, exceptions, video)
194 const additionalActors = await getActorsInvolvedInVideo(video, t)
195 const additionalFollowerUrls = additionalActors.map(a => a.followersUrl)
196
197 await forwardActivity(activity, t, exceptions, additionalFollowerUrls)
198 } 194 }
199 }) 195 })
200} 196}
diff --git a/server/lib/activitypub/process/process-like.ts b/server/lib/activitypub/process/process-like.ts
index d219e76eb..f1642f038 100644
--- a/server/lib/activitypub/process/process-like.ts
+++ b/server/lib/activitypub/process/process-like.ts
@@ -4,8 +4,9 @@ import { sequelizeTypescript } from '../../../initializers'
4import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 4import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
5import { ActorModel } from '../../../models/activitypub/actor' 5import { ActorModel } from '../../../models/activitypub/actor'
6import { getOrCreateActorAndServerAndModel } from '../actor' 6import { getOrCreateActorAndServerAndModel } from '../actor'
7import { forwardActivity } from '../send/utils' 7import { forwardActivity, forwardVideoRelatedActivity } from '../send/utils'
8import { getOrCreateAccountAndVideoAndChannel } from '../videos' 8import { getOrCreateAccountAndVideoAndChannel } from '../videos'
9import { getActorsInvolvedInVideo } from '../audience'
9 10
10async function processLikeActivity (activity: ActivityLike) { 11async function processLikeActivity (activity: ActivityLike) {
11 const actor = await getOrCreateActorAndServerAndModel(activity.actor) 12 const actor = await getOrCreateActorAndServerAndModel(activity.actor)
@@ -54,7 +55,8 @@ async function createVideoLike (byActor: ActorModel, activity: ActivityLike) {
54 if (video.isOwned() && created === true) { 55 if (video.isOwned() && created === true) {
55 // Don't resend the activity to the sender 56 // Don't resend the activity to the sender
56 const exceptions = [ byActor ] 57 const exceptions = [ byActor ]
57 await forwardActivity(activity, t, exceptions) 58
59 await forwardVideoRelatedActivity(activity, t, exceptions, video)
58 } 60 }
59 }) 61 })
60} 62}
diff --git a/server/lib/activitypub/process/process-undo.ts b/server/lib/activitypub/process/process-undo.ts
index d023f7029..37db58e1a 100644
--- a/server/lib/activitypub/process/process-undo.ts
+++ b/server/lib/activitypub/process/process-undo.ts
@@ -8,7 +8,7 @@ import { AccountModel } from '../../../models/account/account'
8import { AccountVideoRateModel } from '../../../models/account/account-video-rate' 8import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
9import { ActorModel } from '../../../models/activitypub/actor' 9import { ActorModel } from '../../../models/activitypub/actor'
10import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 10import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
11import { forwardActivity } from '../send/utils' 11import { forwardVideoRelatedActivity } from '../send/utils'
12import { getOrCreateAccountAndVideoAndChannel } from '../videos' 12import { getOrCreateAccountAndVideoAndChannel } from '../videos'
13import { VideoShareModel } from '../../../models/video/video-share' 13import { VideoShareModel } from '../../../models/video/video-share'
14 14
@@ -67,7 +67,8 @@ async function undoLike (actorUrl: string, activity: ActivityUndo) {
67 if (video.isOwned()) { 67 if (video.isOwned()) {
68 // Don't resend the activity to the sender 68 // Don't resend the activity to the sender
69 const exceptions = [ byAccount.Actor ] 69 const exceptions = [ byAccount.Actor ]
70 await forwardActivity(activity, t, exceptions) 70
71 await forwardVideoRelatedActivity(activity, t, exceptions, video)
71 } 72 }
72 }) 73 })
73} 74}
@@ -99,7 +100,8 @@ async function undoDislike (actorUrl: string, activity: ActivityUndo) {
99 if (video.isOwned()) { 100 if (video.isOwned()) {
100 // Don't resend the activity to the sender 101 // Don't resend the activity to the sender
101 const exceptions = [ byAccount.Actor ] 102 const exceptions = [ byAccount.Actor ]
102 await forwardActivity(activity, t, exceptions) 103
104 await forwardVideoRelatedActivity(activity, t, exceptions, video)
103 } 105 }
104 }) 106 })
105} 107}
@@ -138,11 +140,19 @@ function processUndoAnnounce (actorUrl: string, announceActivity: ActivityAnnoun
138 140
139function undoAnnounce (actorUrl: string, announceActivity: ActivityAnnounce) { 141function undoAnnounce (actorUrl: string, announceActivity: ActivityAnnounce) {
140 return sequelizeTypescript.transaction(async t => { 142 return sequelizeTypescript.transaction(async t => {
143 const byAccount = await AccountModel.loadByUrl(actorUrl, t)
144 if (!byAccount) throw new Error('Unknown account ' + actorUrl)
145
141 const share = await VideoShareModel.loadByUrl(announceActivity.id, t) 146 const share = await VideoShareModel.loadByUrl(announceActivity.id, t)
142 if (!share) throw new Error(`'Unknown video share ${announceActivity.id}.`) 147 if (!share) throw new Error(`'Unknown video share ${announceActivity.id}.`)
143 148
144 await share.destroy({ transaction: t }) 149 await share.destroy({ transaction: t })
145 150
146 return undefined 151 if (share.Video.isOwned()) {
152 // Don't resend the activity to the sender
153 const exceptions = [ byAccount.Actor ]
154
155 await forwardVideoRelatedActivity(announceActivity, t, exceptions, share.Video)
156 }
147 }) 157 })
148} 158}
diff --git a/server/lib/activitypub/send/utils.ts b/server/lib/activitypub/send/utils.ts
index 80d4463ff..241db6c8c 100644
--- a/server/lib/activitypub/send/utils.ts
+++ b/server/lib/activitypub/send/utils.ts
@@ -4,6 +4,21 @@ import { logger } from '../../../helpers/logger'
4import { ActorModel } from '../../../models/activitypub/actor' 4import { ActorModel } from '../../../models/activitypub/actor'
5import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 5import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
6import { JobQueue } from '../../job-queue' 6import { JobQueue } from '../../job-queue'
7import { VideoModel } from '../../../models/video/video'
8import { getActorsInvolvedInVideo } from '../audience'
9
10async function forwardVideoRelatedActivity (
11 activity: Activity,
12 t: Transaction,
13 followersException: ActorModel[] = [],
14 video: VideoModel
15) {
16 // Mastodon does not add our announces in audience, so we forward to them manually
17 const additionalActors = await getActorsInvolvedInVideo(video, t)
18 const additionalFollowerUrls = additionalActors.map(a => a.followersUrl)
19
20 return forwardActivity(activity, t, followersException, additionalFollowerUrls)
21}
7 22
8async function forwardActivity ( 23async function forwardActivity (
9 activity: Activity, 24 activity: Activity,
@@ -91,7 +106,8 @@ export {
91 broadcastToFollowers, 106 broadcastToFollowers,
92 unicastTo, 107 unicastTo,
93 forwardActivity, 108 forwardActivity,
94 broadcastToActors 109 broadcastToActors,
110 forwardVideoRelatedActivity
95} 111}
96 112
97// --------------------------------------------------------------------------- 113// ---------------------------------------------------------------------------