diff options
Diffstat (limited to 'server/lib/activitypub/send/send-undo.ts')
-rw-r--r-- | server/lib/activitypub/send/send-undo.ts | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/server/lib/activitypub/send/send-undo.ts b/server/lib/activitypub/send/send-undo.ts index 699f920f0..92271b700 100644 --- a/server/lib/activitypub/send/send-undo.ts +++ b/server/lib/activitypub/send/send-undo.ts | |||
@@ -6,13 +6,13 @@ import { | |||
6 | ActivityLike, | 6 | ActivityLike, |
7 | ActivityUndo | 7 | ActivityUndo |
8 | } from '../../../../shared/models/activitypub' | 8 | } from '../../../../shared/models/activitypub' |
9 | import { AccountModel } from '../../../models/account/account' | 9 | import { ActorModel } from '../../../models/activitypub/actor' |
10 | import { AccountFollowModel } from '../../../models/account/account-follow' | 10 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
11 | import { VideoModel } from '../../../models/video/video' | 11 | import { VideoModel } from '../../../models/video/video' |
12 | import { getAccountFollowActivityPubUrl, getUndoActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from '../url' | 12 | import { getActorFollowActivityPubUrl, getUndoActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from '../url' |
13 | import { | 13 | import { |
14 | broadcastToFollowers, | 14 | broadcastToFollowers, |
15 | getAccountsInvolvedInVideo, | 15 | getActorsInvolvedInVideo, |
16 | getAudience, | 16 | getAudience, |
17 | getObjectFollowersAudience, | 17 | getObjectFollowersAudience, |
18 | getOriginVideoAudience, | 18 | getOriginVideoAudience, |
@@ -22,11 +22,11 @@ import { createActivityData, createDislikeActivityData } from './send-create' | |||
22 | import { followActivityData } from './send-follow' | 22 | import { followActivityData } from './send-follow' |
23 | import { likeActivityData } from './send-like' | 23 | import { likeActivityData } from './send-like' |
24 | 24 | ||
25 | async function sendUndoFollow (accountFollow: AccountFollowModel, t: Transaction) { | 25 | async function sendUndoFollow (actorFollow: ActorFollowModel, t: Transaction) { |
26 | const me = accountFollow.AccountFollower | 26 | const me = actorFollow.ActorFollower |
27 | const following = accountFollow.AccountFollowing | 27 | const following = actorFollow.ActorFollowing |
28 | 28 | ||
29 | const followUrl = getAccountFollowActivityPubUrl(accountFollow) | 29 | const followUrl = getActorFollowActivityPubUrl(actorFollow) |
30 | const undoUrl = getUndoActivityPubUrl(followUrl) | 30 | const undoUrl = getUndoActivityPubUrl(followUrl) |
31 | 31 | ||
32 | const object = followActivityData(followUrl, me, following) | 32 | const object = followActivityData(followUrl, me, following) |
@@ -35,58 +35,58 @@ async function sendUndoFollow (accountFollow: AccountFollowModel, t: Transaction | |||
35 | return unicastTo(data, me, following.inboxUrl, t) | 35 | return unicastTo(data, me, following.inboxUrl, t) |
36 | } | 36 | } |
37 | 37 | ||
38 | async function sendUndoLikeToOrigin (byAccount: AccountModel, video: VideoModel, t: Transaction) { | 38 | async function sendUndoLikeToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { |
39 | const likeUrl = getVideoLikeActivityPubUrl(byAccount, video) | 39 | const likeUrl = getVideoLikeActivityPubUrl(byActor, video) |
40 | const undoUrl = getUndoActivityPubUrl(likeUrl) | 40 | const undoUrl = getUndoActivityPubUrl(likeUrl) |
41 | 41 | ||
42 | const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t) | 42 | const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, t) |
43 | const audience = getOriginVideoAudience(video, accountsInvolvedInVideo) | 43 | const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) |
44 | const object = await likeActivityData(likeUrl, byAccount, video, t) | 44 | const object = await likeActivityData(likeUrl, byActor, video, t) |
45 | const data = await undoActivityData(undoUrl, byAccount, object, t, audience) | 45 | const data = await undoActivityData(undoUrl, byActor, object, t, audience) |
46 | 46 | ||
47 | return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) | 47 | return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl, t) |
48 | } | 48 | } |
49 | 49 | ||
50 | async function sendUndoLikeToVideoFollowers (byAccount: AccountModel, video: VideoModel, t: Transaction) { | 50 | async function sendUndoLikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { |
51 | const likeUrl = getVideoLikeActivityPubUrl(byAccount, video) | 51 | const likeUrl = getVideoLikeActivityPubUrl(byActor, video) |
52 | const undoUrl = getUndoActivityPubUrl(likeUrl) | 52 | const undoUrl = getUndoActivityPubUrl(likeUrl) |
53 | 53 | ||
54 | const toAccountsFollowers = await getAccountsInvolvedInVideo(video, t) | 54 | const toActorsFollowers = await getActorsInvolvedInVideo(video, t) |
55 | const audience = getObjectFollowersAudience(toAccountsFollowers) | 55 | const audience = getObjectFollowersAudience(toActorsFollowers) |
56 | const object = await likeActivityData(likeUrl, byAccount, video, t) | 56 | const object = await likeActivityData(likeUrl, byActor, video, t) |
57 | const data = await undoActivityData(undoUrl, byAccount, object, t, audience) | 57 | const data = await undoActivityData(undoUrl, byActor, object, t, audience) |
58 | 58 | ||
59 | const followersException = [ byAccount ] | 59 | const followersException = [ byActor ] |
60 | return broadcastToFollowers(data, byAccount, toAccountsFollowers, t, followersException) | 60 | return broadcastToFollowers(data, byActor, toActorsFollowers, t, followersException) |
61 | } | 61 | } |
62 | 62 | ||
63 | async function sendUndoDislikeToOrigin (byAccount: AccountModel, video: VideoModel, t: Transaction) { | 63 | async function sendUndoDislikeToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { |
64 | const dislikeUrl = getVideoDislikeActivityPubUrl(byAccount, video) | 64 | const dislikeUrl = getVideoDislikeActivityPubUrl(byActor, video) |
65 | const undoUrl = getUndoActivityPubUrl(dislikeUrl) | 65 | const undoUrl = getUndoActivityPubUrl(dislikeUrl) |
66 | 66 | ||
67 | const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t) | 67 | const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, t) |
68 | const audience = getOriginVideoAudience(video, accountsInvolvedInVideo) | 68 | const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) |
69 | const dislikeActivity = createDislikeActivityData(byAccount, video) | 69 | const dislikeActivity = createDislikeActivityData(byActor, video) |
70 | const object = await createActivityData(undoUrl, byAccount, dislikeActivity, t) | 70 | const object = await createActivityData(undoUrl, byActor, dislikeActivity, t) |
71 | 71 | ||
72 | const data = await undoActivityData(undoUrl, byAccount, object, t, audience) | 72 | const data = await undoActivityData(undoUrl, byActor, object, t, audience) |
73 | 73 | ||
74 | return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) | 74 | return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl, t) |
75 | } | 75 | } |
76 | 76 | ||
77 | async function sendUndoDislikeToVideoFollowers (byAccount: AccountModel, video: VideoModel, t: Transaction) { | 77 | async function sendUndoDislikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { |
78 | const dislikeUrl = getVideoDislikeActivityPubUrl(byAccount, video) | 78 | const dislikeUrl = getVideoDislikeActivityPubUrl(byActor, video) |
79 | const undoUrl = getUndoActivityPubUrl(dislikeUrl) | 79 | const undoUrl = getUndoActivityPubUrl(dislikeUrl) |
80 | 80 | ||
81 | const dislikeActivity = createDislikeActivityData(byAccount, video) | 81 | const dislikeActivity = createDislikeActivityData(byActor, video) |
82 | const object = await createActivityData(undoUrl, byAccount, dislikeActivity, t) | 82 | const object = await createActivityData(undoUrl, byActor, dislikeActivity, t) |
83 | 83 | ||
84 | const data = await undoActivityData(undoUrl, byAccount, object, t) | 84 | const data = await undoActivityData(undoUrl, byActor, object, t) |
85 | 85 | ||
86 | const toAccountsFollowers = await getAccountsInvolvedInVideo(video, t) | 86 | const toActorsFollowers = await getActorsInvolvedInVideo(video, t) |
87 | 87 | ||
88 | const followersException = [ byAccount ] | 88 | const followersException = [ byActor ] |
89 | return broadcastToFollowers(data, byAccount, toAccountsFollowers, t, followersException) | 89 | return broadcastToFollowers(data, byActor, toActorsFollowers, t, followersException) |
90 | } | 90 | } |
91 | 91 | ||
92 | // --------------------------------------------------------------------------- | 92 | // --------------------------------------------------------------------------- |
@@ -103,19 +103,19 @@ export { | |||
103 | 103 | ||
104 | async function undoActivityData ( | 104 | async function undoActivityData ( |
105 | url: string, | 105 | url: string, |
106 | byAccount: AccountModel, | 106 | byActor: ActorModel, |
107 | object: ActivityFollow | ActivityLike | ActivityCreate, | 107 | object: ActivityFollow | ActivityLike | ActivityCreate, |
108 | t: Transaction, | 108 | t: Transaction, |
109 | audience?: ActivityAudience | 109 | audience?: ActivityAudience |
110 | ): Promise<ActivityUndo> { | 110 | ): Promise<ActivityUndo> { |
111 | if (!audience) { | 111 | if (!audience) { |
112 | audience = await getAudience(byAccount, t) | 112 | audience = await getAudience(byActor, t) |
113 | } | 113 | } |
114 | 114 | ||
115 | return { | 115 | return { |
116 | type: 'Undo', | 116 | type: 'Undo', |
117 | id: url, | 117 | id: url, |
118 | actor: byAccount.url, | 118 | actor: byActor.url, |
119 | to: audience.to, | 119 | to: audience.to, |
120 | cc: audience.cc, | 120 | cc: audience.cc, |
121 | object | 121 | object |