diff options
Diffstat (limited to 'server/lib/activitypub/share.ts')
-rw-r--r-- | server/lib/activitypub/share.ts | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts index fd374d03d..53ecd3dab 100644 --- a/server/lib/activitypub/share.ts +++ b/server/lib/activitypub/share.ts | |||
@@ -4,28 +4,36 @@ import { getServerActor } from '../../helpers/utils' | |||
4 | import { VideoModel } from '../../models/video/video' | 4 | import { VideoModel } from '../../models/video/video' |
5 | import { VideoShareModel } from '../../models/video/video-share' | 5 | import { VideoShareModel } from '../../models/video/video-share' |
6 | import { sendVideoAnnounceToFollowers } from './send' | 6 | import { sendVideoAnnounceToFollowers } from './send' |
7 | import { getAnnounceActivityPubUrl } from './url' | ||
7 | 8 | ||
8 | async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) { | 9 | async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) { |
9 | if (video.privacy === VideoPrivacy.PRIVATE) return undefined | 10 | if (video.privacy === VideoPrivacy.PRIVATE) return undefined |
10 | 11 | ||
11 | const serverActor = await getServerActor() | 12 | const serverActor = await getServerActor() |
12 | 13 | ||
13 | const serverShare = VideoShareModel.create({ | 14 | const serverShareUrl = getAnnounceActivityPubUrl(video.url, serverActor) |
15 | const serverSharePromise = VideoShareModel.create({ | ||
14 | actorId: serverActor.id, | 16 | actorId: serverActor.id, |
15 | videoId: video.id | 17 | videoId: video.id, |
18 | url: serverShareUrl | ||
16 | }, { transaction: t }) | 19 | }, { transaction: t }) |
17 | 20 | ||
18 | const videoChannelShare = VideoShareModel.create({ | 21 | const videoChannelShareUrl = getAnnounceActivityPubUrl(video.url, video.VideoChannel.Actor) |
22 | const videoChannelSharePromise = VideoShareModel.create({ | ||
19 | actorId: video.VideoChannel.actorId, | 23 | actorId: video.VideoChannel.actorId, |
20 | videoId: video.id | 24 | videoId: video.id, |
25 | url: videoChannelShareUrl | ||
21 | }, { transaction: t }) | 26 | }, { transaction: t }) |
22 | 27 | ||
23 | await Promise.all([ | 28 | const [ serverShare, videoChannelShare ] = await Promise.all([ |
24 | serverShare, | 29 | serverSharePromise, |
25 | videoChannelShare | 30 | videoChannelSharePromise |
26 | ]) | 31 | ]) |
27 | 32 | ||
28 | return sendVideoAnnounceToFollowers(serverActor, video, t) | 33 | return Promise.all([ |
34 | sendVideoAnnounceToFollowers(serverActor, videoChannelShare, video, t), | ||
35 | sendVideoAnnounceToFollowers(serverActor, serverShare, video, t) | ||
36 | ]) | ||
29 | } | 37 | } |
30 | 38 | ||
31 | export { | 39 | export { |