diff options
author | Chocobozzz <me@florianbigard.com> | 2022-11-14 12:06:31 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-11-14 13:03:54 +0100 |
commit | f713f36bdf6f696ab0fe8a309035a09e864a48ca (patch) | |
tree | 3135c3a51fec3f1add56ff0ed559a5c9c499914a /server/helpers | |
parent | 44e702ded455c118f9908b70d25e7c7e5512abe9 (diff) | |
download | PeerTube-f713f36bdf6f696ab0fe8a309035a09e864a48ca.tar.gz PeerTube-f713f36bdf6f696ab0fe8a309035a09e864a48ca.tar.zst PeerTube-f713f36bdf6f696ab0fe8a309035a09e864a48ca.zip |
Federate entire description
Introduce an explicit field truncatedDescription
description in video list is deprecated
description in video get will contain the entire description
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/activitypub/videos.ts | 10 | ||||
-rw-r--r-- | server/helpers/custom-validators/videos.ts | 5 |
2 files changed, 5 insertions, 10 deletions
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index 2a2f008b9..97b3577af 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts | |||
@@ -7,11 +7,11 @@ import { peertubeTruncate } from '../../core-utils' | |||
7 | import { isArray, isBooleanValid, isDateValid, isUUIDValid } from '../misc' | 7 | import { isArray, isBooleanValid, isDateValid, isUUIDValid } from '../misc' |
8 | import { isLiveLatencyModeValid } from '../video-lives' | 8 | import { isLiveLatencyModeValid } from '../video-lives' |
9 | import { | 9 | import { |
10 | isVideoDescriptionValid, | ||
10 | isVideoDurationValid, | 11 | isVideoDurationValid, |
11 | isVideoNameValid, | 12 | isVideoNameValid, |
12 | isVideoStateValid, | 13 | isVideoStateValid, |
13 | isVideoTagValid, | 14 | isVideoTagValid, |
14 | isVideoTruncatedDescriptionValid, | ||
15 | isVideoViewsValid | 15 | isVideoViewsValid |
16 | } from '../videos' | 16 | } from '../videos' |
17 | import { isActivityPubUrlValid, isActivityPubVideoDurationValid, isBaseActivityValid, setValidAttributedTo } from './misc' | 17 | import { isActivityPubUrlValid, isActivityPubVideoDurationValid, isBaseActivityValid, setValidAttributedTo } from './misc' |
@@ -32,7 +32,7 @@ function sanitizeAndCheckVideoTorrentObject (video: any) { | |||
32 | logger.debug('Video has invalid urls', { video }) | 32 | logger.debug('Video has invalid urls', { video }) |
33 | return false | 33 | return false |
34 | } | 34 | } |
35 | if (!setRemoteVideoTruncatedContent(video)) { | 35 | if (!setRemoteVideoContent(video)) { |
36 | logger.debug('Video has invalid content', { video }) | 36 | logger.debug('Video has invalid content', { video }) |
37 | return false | 37 | return false |
38 | } | 38 | } |
@@ -168,7 +168,7 @@ function isRemoteStringIdentifierValid (data: any) { | |||
168 | } | 168 | } |
169 | 169 | ||
170 | function isRemoteVideoContentValid (mediaType: string, content: string) { | 170 | function isRemoteVideoContentValid (mediaType: string, content: string) { |
171 | return mediaType === 'text/markdown' && isVideoTruncatedDescriptionValid(content) | 171 | return mediaType === 'text/markdown' && isVideoDescriptionValid(content) |
172 | } | 172 | } |
173 | 173 | ||
174 | function setValidRemoteIcon (video: any) { | 174 | function setValidRemoteIcon (video: any) { |
@@ -194,9 +194,9 @@ function setValidRemoteVideoUrls (video: any) { | |||
194 | return true | 194 | return true |
195 | } | 195 | } |
196 | 196 | ||
197 | function setRemoteVideoTruncatedContent (video: any) { | 197 | function setRemoteVideoContent (video: any) { |
198 | if (video.content) { | 198 | if (video.content) { |
199 | video.content = peertubeTruncate(video.content, { length: CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max }) | 199 | video.content = peertubeTruncate(video.content, { length: CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max }) |
200 | } | 200 | } |
201 | 201 | ||
202 | return true | 202 | return true |
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 3ebfe2937..9e8177f77 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts | |||
@@ -45,10 +45,6 @@ function isVideoDurationValid (value: string) { | |||
45 | return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION) | 45 | return exists(value) && validator.isInt(value + '', VIDEOS_CONSTRAINTS_FIELDS.DURATION) |
46 | } | 46 | } |
47 | 47 | ||
48 | function isVideoTruncatedDescriptionValid (value: string) { | ||
49 | return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.TRUNCATED_DESCRIPTION) | ||
50 | } | ||
51 | |||
52 | function isVideoDescriptionValid (value: string) { | 48 | function isVideoDescriptionValid (value: string) { |
53 | return value === null || (exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION)) | 49 | return value === null || (exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.DESCRIPTION)) |
54 | } | 50 | } |
@@ -151,7 +147,6 @@ export { | |||
151 | isVideoCategoryValid, | 147 | isVideoCategoryValid, |
152 | isVideoLicenceValid, | 148 | isVideoLicenceValid, |
153 | isVideoLanguageValid, | 149 | isVideoLanguageValid, |
154 | isVideoTruncatedDescriptionValid, | ||
155 | isVideoDescriptionValid, | 150 | isVideoDescriptionValid, |
156 | isVideoFileInfoHashValid, | 151 | isVideoFileInfoHashValid, |
157 | isVideoNameValid, | 152 | isVideoNameValid, |