aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators/activitypub/videos.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-12 19:02:00 +0200
committerChocobozzz <me@florianbigard.com>2018-07-16 11:50:08 +0200
commit40e87e9ecc54e3513fb586928330a7855eb192c6 (patch)
treeaf1111ecba85f9cd8286811ff332a67cf21be2f6 /server/helpers/custom-validators/activitypub/videos.ts
parentd4557fd3ecc8d4ed4fb0e5c868929bc36c959ed2 (diff)
downloadPeerTube-40e87e9ecc54e3513fb586928330a7855eb192c6.tar.gz
PeerTube-40e87e9ecc54e3513fb586928330a7855eb192c6.tar.zst
PeerTube-40e87e9ecc54e3513fb586928330a7855eb192c6.zip
Implement captions/subtitles
Diffstat (limited to 'server/helpers/custom-validators/activitypub/videos.ts')
-rw-r--r--server/helpers/custom-validators/activitypub/videos.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts
index 37c90a0c8..d97bbd2a9 100644
--- a/server/helpers/custom-validators/activitypub/videos.ts
+++ b/server/helpers/custom-validators/activitypub/videos.ts
@@ -51,6 +51,7 @@ function sanitizeAndCheckVideoTorrentObject (video: any) {
51 if (!setValidRemoteVideoUrls(video)) return false 51 if (!setValidRemoteVideoUrls(video)) return false
52 if (!setRemoteVideoTruncatedContent(video)) return false 52 if (!setRemoteVideoTruncatedContent(video)) return false
53 if (!setValidAttributedTo(video)) return false 53 if (!setValidAttributedTo(video)) return false
54 if (!setValidRemoteCaptions(video)) return false
54 55
55 // Default attributes 56 // Default attributes
56 if (!isVideoStateValid(video.state)) video.state = VideoState.PUBLISHED 57 if (!isVideoStateValid(video.state)) video.state = VideoState.PUBLISHED
@@ -98,6 +99,18 @@ function setValidRemoteTags (video: any) {
98 return true 99 return true
99} 100}
100 101
102function setValidRemoteCaptions (video: any) {
103 if (!video.subtitleLanguage) video.subtitleLanguage = []
104
105 if (Array.isArray(video.subtitleLanguage) === false) return false
106
107 video.subtitleLanguage = video.subtitleLanguage.filter(caption => {
108 return isRemoteStringIdentifierValid(caption)
109 })
110
111 return true
112}
113
101function isRemoteNumberIdentifierValid (data: any) { 114function isRemoteNumberIdentifierValid (data: any) {
102 return validator.isInt(data.identifier, { min: 0 }) 115 return validator.isInt(data.identifier, { min: 0 })
103} 116}