diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/process/process-undo.ts | 10 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-announce.ts | 5 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-update.ts | 10 | ||||
-rw-r--r-- | server/lib/activitypub/share.ts | 2 |
4 files changed, 20 insertions, 7 deletions
diff --git a/server/lib/activitypub/process/process-undo.ts b/server/lib/activitypub/process/process-undo.ts index eab9e3d61..1c1de8827 100644 --- a/server/lib/activitypub/process/process-undo.ts +++ b/server/lib/activitypub/process/process-undo.ts | |||
@@ -104,17 +104,19 @@ function processUndoFollow (actorUrl: string, followActivity: ActivityFollow) { | |||
104 | 104 | ||
105 | function processUndoAnnounce (actorUrl: string, announceActivity: ActivityAnnounce) { | 105 | function processUndoAnnounce (actorUrl: string, announceActivity: ActivityAnnounce) { |
106 | return sequelizeTypescript.transaction(async t => { | 106 | return sequelizeTypescript.transaction(async t => { |
107 | const byAccount = await AccountModel.loadByUrl(actorUrl, t) | 107 | const byActor = await ActorModel.loadByUrl(actorUrl, t) |
108 | if (!byAccount) throw new Error('Unknown account ' + actorUrl) | 108 | if (!byActor) throw new Error('Unknown actor ' + actorUrl) |
109 | 109 | ||
110 | const share = await VideoShareModel.loadByUrl(announceActivity.id, t) | 110 | const share = await VideoShareModel.loadByUrl(announceActivity.id, t) |
111 | if (!share) throw new Error(`'Unknown video share ${announceActivity.id}.`) | 111 | if (!share) throw new Error(`Unknown video share ${announceActivity.id}.`) |
112 | |||
113 | if (share.actorId !== byActor.id) throw new Error(`${share.url} is not shared by ${byActor.url}.`) | ||
112 | 114 | ||
113 | await share.destroy({ transaction: t }) | 115 | await share.destroy({ transaction: t }) |
114 | 116 | ||
115 | if (share.Video.isOwned()) { | 117 | if (share.Video.isOwned()) { |
116 | // Don't resend the activity to the sender | 118 | // Don't resend the activity to the sender |
117 | const exceptions = [ byAccount.Actor ] | 119 | const exceptions = [ byActor ] |
118 | 120 | ||
119 | await forwardVideoRelatedActivity(announceActivity, t, exceptions, share.Video) | 121 | await forwardVideoRelatedActivity(announceActivity, t, exceptions, share.Video) |
120 | } | 122 | } |
diff --git a/server/lib/activitypub/send/send-announce.ts b/server/lib/activitypub/send/send-announce.ts index 1ab05ca3c..352813d73 100644 --- a/server/lib/activitypub/send/send-announce.ts +++ b/server/lib/activitypub/send/send-announce.ts | |||
@@ -20,7 +20,10 @@ async function sendVideoAnnounce (byActor: ActorModel, videoShare: VideoShareMod | |||
20 | 20 | ||
21 | logger.info('Creating job to send announce %s.', videoShare.url) | 21 | logger.info('Creating job to send announce %s.', videoShare.url) |
22 | 22 | ||
23 | return broadcastToFollowers(data, byActor, [ byActor ], t) | 23 | const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, t) |
24 | const followersException = [ byActor ] | ||
25 | |||
26 | return broadcastToFollowers(data, byActor, actorsInvolvedInVideo, t, followersException) | ||
24 | } | 27 | } |
25 | 28 | ||
26 | function announceActivityData (url: string, byActor: ActorModel, object: string, audience?: ActivityAudience): ActivityAnnounce { | 29 | function announceActivityData (url: string, byActor: ActorModel, object: string, audience?: ActivityAudience): ActivityAnnounce { |
diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts index 17d4f185c..6f1d80898 100644 --- a/server/lib/activitypub/send/send-update.ts +++ b/server/lib/activitypub/send/send-update.ts | |||
@@ -10,13 +10,19 @@ import { getUpdateActivityPubUrl } from '../url' | |||
10 | import { broadcastToFollowers } from './utils' | 10 | import { broadcastToFollowers } from './utils' |
11 | import { audiencify, getAudience } from '../audience' | 11 | import { audiencify, getAudience } from '../audience' |
12 | import { logger } from '../../../helpers/logger' | 12 | import { logger } from '../../../helpers/logger' |
13 | import { videoFeedsValidator } from '../../../middlewares/validators' | ||
14 | import { VideoCaptionModel } from '../../../models/video/video-caption' | ||
13 | 15 | ||
14 | async function sendUpdateVideo (video: VideoModel, t: Transaction) { | 16 | async function sendUpdateVideo (video: VideoModel, t: Transaction, overrodeByActor?: ActorModel) { |
15 | logger.info('Creating job to update video %s.', video.url) | 17 | logger.info('Creating job to update video %s.', video.url) |
16 | 18 | ||
17 | const byActor = video.VideoChannel.Account.Actor | 19 | const byActor = overrodeByActor ? overrodeByActor : video.VideoChannel.Account.Actor |
18 | 20 | ||
19 | const url = getUpdateActivityPubUrl(video.url, video.updatedAt.toISOString()) | 21 | const url = getUpdateActivityPubUrl(video.url, video.updatedAt.toISOString()) |
22 | |||
23 | // Needed to build the AP object | ||
24 | if (!video.VideoCaptions) video.VideoCaptions = await video.$get('VideoCaptions') as VideoCaptionModel[] | ||
25 | |||
20 | const videoObject = video.toActivityPubObject() | 26 | const videoObject = video.toActivityPubObject() |
21 | const audience = getAudience(byActor, video.privacy === VideoPrivacy.PUBLIC) | 27 | const audience = getAudience(byActor, video.privacy === VideoPrivacy.PUBLIC) |
22 | 28 | ||
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts index fe3d73e9b..3ff60a97c 100644 --- a/server/lib/activitypub/share.ts +++ b/server/lib/activitypub/share.ts | |||
@@ -22,6 +22,8 @@ async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) | |||
22 | } | 22 | } |
23 | 23 | ||
24 | async function changeVideoChannelShare (video: VideoModel, oldVideoChannel: VideoChannelModel, t: Transaction) { | 24 | async function changeVideoChannelShare (video: VideoModel, oldVideoChannel: VideoChannelModel, t: Transaction) { |
25 | logger.info('Updating video channel of video %s: %s -> %s.', video.uuid, oldVideoChannel.name, video.VideoChannel.name) | ||
26 | |||
25 | await undoShareByVideoChannel(video, oldVideoChannel, t) | 27 | await undoShareByVideoChannel(video, oldVideoChannel, t) |
26 | 28 | ||
27 | await shareByVideoChannel(video, t) | 29 | await shareByVideoChannel(video, t) |