aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/send/send-create.ts2
-rw-r--r--server/lib/activitypub/send/send-update.ts2
-rw-r--r--server/lib/activitypub/share.ts5
-rw-r--r--server/lib/activitypub/videos.ts2
-rw-r--r--server/lib/client-html.ts2
-rw-r--r--server/lib/schedulers/update-videos-scheduler.ts10
6 files changed, 10 insertions, 13 deletions
diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts
index edbc14a73..1709d8348 100644
--- a/server/lib/activitypub/send/send-create.ts
+++ b/server/lib/activitypub/send/send-create.ts
@@ -18,7 +18,7 @@ import {
18} from '../../../typings/models' 18} from '../../../typings/models'
19 19
20async function sendCreateVideo (video: MVideoAP, t: Transaction) { 20async function sendCreateVideo (video: MVideoAP, t: Transaction) {
21 if (video.privacy === VideoPrivacy.PRIVATE) return undefined 21 if (!video.hasPrivacyForFederation()) return undefined
22 22
23 logger.info('Creating job to send video creation of %s.', video.url) 23 logger.info('Creating job to send video creation of %s.', video.url)
24 24
diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts
index 44e0e1161..cb14b8dbf 100644
--- a/server/lib/activitypub/send/send-update.ts
+++ b/server/lib/activitypub/send/send-update.ts
@@ -25,7 +25,7 @@ import {
25async function sendUpdateVideo (videoArg: MVideoAPWithoutCaption, t: Transaction, overrodeByActor?: MActor) { 25async function sendUpdateVideo (videoArg: MVideoAPWithoutCaption, t: Transaction, overrodeByActor?: MActor) {
26 const video = videoArg as MVideoAP 26 const video = videoArg as MVideoAP
27 27
28 if (video.privacy === VideoPrivacy.PRIVATE) return undefined 28 if (!video.hasPrivacyForFederation()) return undefined
29 29
30 logger.info('Creating job to update video %s.', video.url) 30 logger.info('Creating job to update video %s.', video.url)
31 31
diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts
index fdca9bed7..e847c4b7d 100644
--- a/server/lib/activitypub/share.ts
+++ b/server/lib/activitypub/share.ts
@@ -1,5 +1,4 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { VideoPrivacy } from '../../../shared/models/videos'
3import { getServerActor } from '../../helpers/utils' 2import { getServerActor } from '../../helpers/utils'
4import { VideoShareModel } from '../../models/video/video-share' 3import { VideoShareModel } from '../../models/video/video-share'
5import { sendUndoAnnounce, sendVideoAnnounce } from './send' 4import { sendUndoAnnounce, sendVideoAnnounce } from './send'
@@ -10,10 +9,10 @@ import { getOrCreateActorAndServerAndModel } from './actor'
10import { logger } from '../../helpers/logger' 9import { logger } from '../../helpers/logger'
11import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' 10import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants'
12import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' 11import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
13import { MChannelActor, MChannelActorLight, MVideo, MVideoAccountLight, MVideoId } from '../../typings/models/video' 12import { MChannelActorLight, MVideo, MVideoAccountLight, MVideoId } from '../../typings/models/video'
14 13
15async function shareVideoByServerAndChannel (video: MVideoAccountLight, t: Transaction) { 14async function shareVideoByServerAndChannel (video: MVideoAccountLight, t: Transaction) {
16 if (video.privacy === VideoPrivacy.PRIVATE) return undefined 15 if (!video.hasPrivacyForFederation()) return undefined
17 16
18 return Promise.all([ 17 return Promise.all([
19 shareByServer(video, t), 18 shareByServer(video, t),
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index d80173e03..2fb1f8d49 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -79,7 +79,7 @@ async function federateVideoIfNeeded (videoArg: MVideoAPWithoutCaption, isNewVid
79 // Check this is not a blacklisted video, or unfederated blacklisted video 79 // Check this is not a blacklisted video, or unfederated blacklisted video
80 (video.isBlacklisted() === false || (isNewVideo === false && video.VideoBlacklist.unfederated === false)) && 80 (video.isBlacklisted() === false || (isNewVideo === false && video.VideoBlacklist.unfederated === false)) &&
81 // Check the video is public/unlisted and published 81 // Check the video is public/unlisted and published
82 video.privacy !== VideoPrivacy.PRIVATE && video.state === VideoState.PUBLISHED 82 video.hasPrivacyForFederation() && video.state === VideoState.PUBLISHED
83 ) { 83 ) {
84 // Fetch more attributes that we will need to serialize in AP object 84 // Fetch more attributes that we will need to serialize in AP object
85 if (isArray(video.VideoCaptions) === false) { 85 if (isArray(video.VideoCaptions) === false) {
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index a1f4ae858..42a30f84f 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -46,7 +46,7 @@ export class ClientHtml {
46 ]) 46 ])
47 47
48 // Let Angular application handle errors 48 // Let Angular application handle errors
49 if (!video || video.privacy === VideoPrivacy.PRIVATE || video.VideoBlacklist) { 49 if (!video || video.privacy === VideoPrivacy.PRIVATE || video.privacy === VideoPrivacy.INTERNAL || video.VideoBlacklist) {
50 return ClientHtml.getIndexHTML(req, res) 50 return ClientHtml.getIndexHTML(req, res)
51 } 51 }
52 52
diff --git a/server/lib/schedulers/update-videos-scheduler.ts b/server/lib/schedulers/update-videos-scheduler.ts
index 293bba91f..350a335d3 100644
--- a/server/lib/schedulers/update-videos-scheduler.ts
+++ b/server/lib/schedulers/update-videos-scheduler.ts
@@ -35,16 +35,14 @@ export class UpdateVideosScheduler extends AbstractScheduler {
35 logger.info('Executing scheduled video update on %s.', video.uuid) 35 logger.info('Executing scheduled video update on %s.', video.uuid)
36 36
37 if (schedule.privacy) { 37 if (schedule.privacy) {
38 const oldPrivacy = video.privacy 38 const wasConfidentialVideo = video.isConfidential()
39 const isNewVideo = oldPrivacy === VideoPrivacy.PRIVATE 39 const isNewVideo = video.isNewVideo(schedule.privacy)
40
41 video.privacy = schedule.privacy
42 if (isNewVideo === true) video.publishedAt = new Date()
43 40
41 video.setPrivacy(schedule.privacy)
44 await video.save({ transaction: t }) 42 await video.save({ transaction: t })
45 await federateVideoIfNeeded(video, isNewVideo, t) 43 await federateVideoIfNeeded(video, isNewVideo, t)
46 44
47 if (oldPrivacy === VideoPrivacy.UNLISTED || oldPrivacy === VideoPrivacy.PRIVATE) { 45 if (wasConfidentialVideo) {
48 const videoToPublish: MVideoFullLight = Object.assign(video, { ScheduleVideoUpdate: schedule, UserVideoHistories: [] }) 46 const videoToPublish: MVideoFullLight = Object.assign(video, { ScheduleVideoUpdate: schedule, UserVideoHistories: [] })
49 publishedVideos.push(videoToPublish) 47 publishedVideos.push(videoToPublish)
50 } 48 }