aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/share.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-19 15:02:36 +0100
committerChocobozzz <me@florianbigard.com>2018-03-19 15:22:18 +0100
commita797728009eb5c26cf55624a4a01e8ecb73f1297 (patch)
tree3dcfe4870986c9bacdfbd2a671143b5dfc4f47d3 /server/lib/activitypub/share.ts
parent9d145133d82c11edfb2781871076b7063cc3ae3d (diff)
downloadPeerTube-a797728009eb5c26cf55624a4a01e8ecb73f1297.tar.gz
PeerTube-a797728009eb5c26cf55624a4a01e8ecb73f1297.tar.zst
PeerTube-a797728009eb5c26cf55624a4a01e8ecb73f1297.zip
Fix video_share_url duplicate key in transcoding job
Diffstat (limited to 'server/lib/activitypub/share.ts')
-rw-r--r--server/lib/activitypub/share.ts47
1 files changed, 31 insertions, 16 deletions
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts
index 53ecd3dab..038f19b7d 100644
--- a/server/lib/activitypub/share.ts
+++ b/server/lib/activitypub/share.ts
@@ -12,27 +12,42 @@ async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction)
12 const serverActor = await getServerActor() 12 const serverActor = await getServerActor()
13 13
14 const serverShareUrl = getAnnounceActivityPubUrl(video.url, serverActor) 14 const serverShareUrl = getAnnounceActivityPubUrl(video.url, serverActor)
15 const serverSharePromise = VideoShareModel.create({ 15 const serverSharePromise = VideoShareModel.findOrCreate({
16 actorId: serverActor.id, 16 defaults: {
17 videoId: video.id, 17 actorId: serverActor.id,
18 url: serverShareUrl 18 videoId: video.id,
19 }, { transaction: t }) 19 url: serverShareUrl
20 },
21 where: {
22 url: serverShareUrl
23 },
24 transaction: t
25 }).then(([ serverShare, created ]) => {
26 if (created) return sendVideoAnnounceToFollowers(serverActor, serverShare, video, t)
27
28 return undefined
29 })
20 30
21 const videoChannelShareUrl = getAnnounceActivityPubUrl(video.url, video.VideoChannel.Actor) 31 const videoChannelShareUrl = getAnnounceActivityPubUrl(video.url, video.VideoChannel.Actor)
22 const videoChannelSharePromise = VideoShareModel.create({ 32 const videoChannelSharePromise = VideoShareModel.findOrCreate({
23 actorId: video.VideoChannel.actorId, 33 defaults: {
24 videoId: video.id, 34 actorId: video.VideoChannel.actorId,
25 url: videoChannelShareUrl 35 videoId: video.id,
26 }, { transaction: t }) 36 url: videoChannelShareUrl
37 },
38 where: {
39 url: videoChannelShareUrl
40 },
41 transaction: t
42 }).then(([ videoChannelShare, created ]) => {
43 if (created) return sendVideoAnnounceToFollowers(serverActor, videoChannelShare, video, t)
27 44
28 const [ serverShare, videoChannelShare ] = await Promise.all([ 45 return undefined
29 serverSharePromise, 46 })
30 videoChannelSharePromise
31 ])
32 47
33 return Promise.all([ 48 return Promise.all([
34 sendVideoAnnounceToFollowers(serverActor, videoChannelShare, video, t), 49 serverSharePromise,
35 sendVideoAnnounceToFollowers(serverActor, serverShare, video, t) 50 videoChannelSharePromise
36 ]) 51 ])
37} 52}
38 53