diff options
Diffstat (limited to 'server/lib/activitypub/send')
-rw-r--r-- | server/lib/activitypub/send/misc.ts | 9 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-accept.ts | 15 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-create.ts | 13 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-like.ts | 7 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-undo.ts | 7 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-update.ts | 10 |
6 files changed, 34 insertions, 27 deletions
diff --git a/server/lib/activitypub/send/misc.ts b/server/lib/activitypub/send/misc.ts index 14101e630..2dc8d3d59 100644 --- a/server/lib/activitypub/send/misc.ts +++ b/server/lib/activitypub/send/misc.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { Activity } from '../../../../shared/models/activitypub' | 2 | import { Activity, ActivityAudience } from '../../../../shared/models/activitypub' |
3 | import { logger } from '../../../helpers' | 3 | import { logger } from '../../../helpers' |
4 | import { ACTIVITY_PUB } from '../../../initializers' | 4 | import { ACTIVITY_PUB } from '../../../initializers' |
5 | import { ActorModel } from '../../../models/activitypub/actor' | 5 | import { ActorModel } from '../../../models/activitypub/actor' |
@@ -116,6 +116,10 @@ async function getAudience (actorSender: ActorModel, t: Transaction, isPublic = | |||
116 | return { to, cc } | 116 | return { to, cc } |
117 | } | 117 | } |
118 | 118 | ||
119 | function audiencify (object: any, audience: ActivityAudience) { | ||
120 | return Object.assign(object, audience) | ||
121 | } | ||
122 | |||
119 | async function computeFollowerUris (toActorFollower: ActorModel[], followersException: ActorModel[], t: Transaction) { | 123 | async function computeFollowerUris (toActorFollower: ActorModel[], followersException: ActorModel[], t: Transaction) { |
120 | const toActorFollowerIds = toActorFollower.map(a => a.id) | 124 | const toActorFollowerIds = toActorFollower.map(a => a.id) |
121 | 125 | ||
@@ -133,5 +137,6 @@ export { | |||
133 | getOriginVideoAudience, | 137 | getOriginVideoAudience, |
134 | getActorsInvolvedInVideo, | 138 | getActorsInvolvedInVideo, |
135 | getObjectFollowersAudience, | 139 | getObjectFollowersAudience, |
136 | forwardActivity | 140 | forwardActivity, |
141 | audiencify | ||
137 | } | 142 | } |
diff --git a/server/lib/activitypub/send/send-accept.ts b/server/lib/activitypub/send/send-accept.ts index 7579884a7..4eaa329d9 100644 --- a/server/lib/activitypub/send/send-accept.ts +++ b/server/lib/activitypub/send/send-accept.ts | |||
@@ -1,16 +1,20 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { ActivityAccept } from '../../../../shared/models/activitypub' | 2 | import { ActivityAccept, ActivityFollow } from '../../../../shared/models/activitypub' |
3 | import { ActorModel } from '../../../models/activitypub/actor' | 3 | import { ActorModel } from '../../../models/activitypub/actor' |
4 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 4 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
5 | import { getActorFollowAcceptActivityPubUrl } from '../url' | 5 | import { getActorFollowAcceptActivityPubUrl, getActorFollowActivityPubUrl } from '../url' |
6 | import { unicastTo } from './misc' | 6 | import { unicastTo } from './misc' |
7 | import { followActivityData } from './send-follow' | ||
7 | 8 | ||
8 | async function sendAccept (actorFollow: ActorFollowModel, t: Transaction) { | 9 | async function sendAccept (actorFollow: ActorFollowModel, t: Transaction) { |
9 | const follower = actorFollow.ActorFollower | 10 | const follower = actorFollow.ActorFollower |
10 | const me = actorFollow.ActorFollowing | 11 | const me = actorFollow.ActorFollowing |
11 | 12 | ||
13 | const followUrl = getActorFollowActivityPubUrl(actorFollow) | ||
14 | const followData = followActivityData(followUrl, follower, me) | ||
15 | |||
12 | const url = getActorFollowAcceptActivityPubUrl(actorFollow) | 16 | const url = getActorFollowAcceptActivityPubUrl(actorFollow) |
13 | const data = acceptActivityData(url, me) | 17 | const data = acceptActivityData(url, me, followData) |
14 | 18 | ||
15 | return unicastTo(data, me, follower.inboxUrl, t) | 19 | return unicastTo(data, me, follower.inboxUrl, t) |
16 | } | 20 | } |
@@ -23,10 +27,11 @@ export { | |||
23 | 27 | ||
24 | // --------------------------------------------------------------------------- | 28 | // --------------------------------------------------------------------------- |
25 | 29 | ||
26 | function acceptActivityData (url: string, byActor: ActorModel): ActivityAccept { | 30 | function acceptActivityData (url: string, byActor: ActorModel, followActivityData: ActivityFollow): ActivityAccept { |
27 | return { | 31 | return { |
28 | type: 'Accept', | 32 | type: 'Accept', |
29 | id: url, | 33 | id: url, |
30 | actor: byActor.url | 34 | actor: byActor.url, |
35 | object: followActivityData | ||
31 | } | 36 | } |
32 | } | 37 | } |
diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts index d26c24838..249dd91dc 100644 --- a/server/lib/activitypub/send/send-create.ts +++ b/server/lib/activitypub/send/send-create.ts | |||
@@ -7,6 +7,7 @@ import { VideoModel } from '../../../models/video/video' | |||
7 | import { VideoAbuseModel } from '../../../models/video/video-abuse' | 7 | import { VideoAbuseModel } from '../../../models/video/video-abuse' |
8 | import { getVideoAbuseActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoViewActivityPubUrl } from '../url' | 8 | import { getVideoAbuseActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoViewActivityPubUrl } from '../url' |
9 | import { | 9 | import { |
10 | audiencify, | ||
10 | broadcastToFollowers, | 11 | broadcastToFollowers, |
11 | getActorsInvolvedInVideo, | 12 | getActorsInvolvedInVideo, |
12 | getAudience, | 13 | getAudience, |
@@ -16,9 +17,11 @@ import { | |||
16 | } from './misc' | 17 | } from './misc' |
17 | 18 | ||
18 | async function sendCreateVideo (video: VideoModel, t: Transaction) { | 19 | async function sendCreateVideo (video: VideoModel, t: Transaction) { |
19 | const byActor = video.VideoChannel.Account.Actor | 20 | if (video.privacy === VideoPrivacy.PRIVATE) return |
20 | 21 | ||
22 | const byActor = video.VideoChannel.Account.Actor | ||
21 | const videoObject = video.toActivityPubObject() | 23 | const videoObject = video.toActivityPubObject() |
24 | |||
22 | const audience = await getAudience(byActor, t, video.privacy === VideoPrivacy.PUBLIC) | 25 | const audience = await getAudience(byActor, t, video.privacy === VideoPrivacy.PUBLIC) |
23 | const data = await createActivityData(video.url, byActor, videoObject, t, audience) | 26 | const data = await createActivityData(video.url, byActor, videoObject, t, audience) |
24 | 27 | ||
@@ -93,14 +96,12 @@ async function createActivityData ( | |||
93 | audience = await getAudience(byActor, t) | 96 | audience = await getAudience(byActor, t) |
94 | } | 97 | } |
95 | 98 | ||
96 | return { | 99 | return audiencify({ |
97 | type: 'Create', | 100 | type: 'Create', |
98 | id: url, | 101 | id: url, |
99 | actor: byActor.url, | 102 | actor: byActor.url, |
100 | to: audience.to, | 103 | object: audiencify(object, audience) |
101 | cc: audience.cc, | 104 | }, audience) |
102 | object | ||
103 | } | ||
104 | } | 105 | } |
105 | 106 | ||
106 | function createDislikeActivityData (byActor: ActorModel, video: VideoModel) { | 107 | function createDislikeActivityData (byActor: ActorModel, video: VideoModel) { |
diff --git a/server/lib/activitypub/send/send-like.ts b/server/lib/activitypub/send/send-like.ts index 7e0c73796..743646455 100644 --- a/server/lib/activitypub/send/send-like.ts +++ b/server/lib/activitypub/send/send-like.ts | |||
@@ -4,6 +4,7 @@ import { ActorModel } from '../../../models/activitypub/actor' | |||
4 | import { VideoModel } from '../../../models/video/video' | 4 | import { VideoModel } from '../../../models/video/video' |
5 | import { getVideoLikeActivityPubUrl } from '../url' | 5 | import { getVideoLikeActivityPubUrl } from '../url' |
6 | import { | 6 | import { |
7 | audiencify, | ||
7 | broadcastToFollowers, | 8 | broadcastToFollowers, |
8 | getActorsInvolvedInVideo, | 9 | getActorsInvolvedInVideo, |
9 | getAudience, | 10 | getAudience, |
@@ -44,14 +45,12 @@ async function likeActivityData ( | |||
44 | audience = await getAudience(byActor, t) | 45 | audience = await getAudience(byActor, t) |
45 | } | 46 | } |
46 | 47 | ||
47 | return { | 48 | return audiencify({ |
48 | type: 'Like', | 49 | type: 'Like', |
49 | id: url, | 50 | id: url, |
50 | actor: byActor.url, | 51 | actor: byActor.url, |
51 | to: audience.to, | ||
52 | cc: audience.cc, | ||
53 | object: video.url | 52 | object: video.url |
54 | } | 53 | }, audience) |
55 | } | 54 | } |
56 | 55 | ||
57 | // --------------------------------------------------------------------------- | 56 | // --------------------------------------------------------------------------- |
diff --git a/server/lib/activitypub/send/send-undo.ts b/server/lib/activitypub/send/send-undo.ts index 92271b700..3a0597fba 100644 --- a/server/lib/activitypub/send/send-undo.ts +++ b/server/lib/activitypub/send/send-undo.ts | |||
@@ -11,6 +11,7 @@ import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | |||
11 | import { VideoModel } from '../../../models/video/video' | 11 | import { VideoModel } from '../../../models/video/video' |
12 | import { getActorFollowActivityPubUrl, getUndoActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from '../url' | 12 | import { getActorFollowActivityPubUrl, getUndoActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from '../url' |
13 | import { | 13 | import { |
14 | audiencify, | ||
14 | broadcastToFollowers, | 15 | broadcastToFollowers, |
15 | getActorsInvolvedInVideo, | 16 | getActorsInvolvedInVideo, |
16 | getAudience, | 17 | getAudience, |
@@ -112,12 +113,10 @@ async function undoActivityData ( | |||
112 | audience = await getAudience(byActor, t) | 113 | audience = await getAudience(byActor, t) |
113 | } | 114 | } |
114 | 115 | ||
115 | return { | 116 | return audiencify({ |
116 | type: 'Undo', | 117 | type: 'Undo', |
117 | id: url, | 118 | id: url, |
118 | actor: byActor.url, | 119 | actor: byActor.url, |
119 | to: audience.to, | ||
120 | cc: audience.cc, | ||
121 | object | 120 | object |
122 | } | 121 | }, audience) |
123 | } | 122 | } |
diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts index 48bbbcac1..b623fec6c 100644 --- a/server/lib/activitypub/send/send-update.ts +++ b/server/lib/activitypub/send/send-update.ts | |||
@@ -5,7 +5,7 @@ import { ActorModel } from '../../../models/activitypub/actor' | |||
5 | import { VideoModel } from '../../../models/video/video' | 5 | import { VideoModel } from '../../../models/video/video' |
6 | import { VideoShareModel } from '../../../models/video/video-share' | 6 | import { VideoShareModel } from '../../../models/video/video-share' |
7 | import { getUpdateActivityPubUrl } from '../url' | 7 | import { getUpdateActivityPubUrl } from '../url' |
8 | import { broadcastToFollowers, getAudience } from './misc' | 8 | import { audiencify, broadcastToFollowers, getAudience } from './misc' |
9 | 9 | ||
10 | async function sendUpdateVideo (video: VideoModel, t: Transaction) { | 10 | async function sendUpdateVideo (video: VideoModel, t: Transaction) { |
11 | const byActor = video.VideoChannel.Account.Actor | 11 | const byActor = video.VideoChannel.Account.Actor |
@@ -41,12 +41,10 @@ async function updateActivityData ( | |||
41 | audience = await getAudience(byActor, t) | 41 | audience = await getAudience(byActor, t) |
42 | } | 42 | } |
43 | 43 | ||
44 | return { | 44 | return audiencify({ |
45 | type: 'Update', | 45 | type: 'Update', |
46 | id: url, | 46 | id: url, |
47 | actor: byActor.url, | 47 | actor: byActor.url, |
48 | to: audience.to, | 48 | object: audiencify(object, audience) |
49 | cc: audience.cc, | 49 | }, audience) |
50 | object | ||
51 | } | ||
52 | } | 50 | } |