diff options
author | Chocobozzz <me@florianbigard.com> | 2018-03-28 11:00:02 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-03-28 11:00:02 +0200 |
commit | c73e83da283c6d4eb094e384d59c4f8eb221507d (patch) | |
tree | 3614954f10ffdb9048bdd10759d1a7f19925b5e9 /server/helpers/custom-validators/activitypub | |
parent | 63f4b132817bfc4d5be4f89077b5a42b97b11a7c (diff) | |
download | PeerTube-c73e83da283c6d4eb094e384d59c4f8eb221507d.tar.gz PeerTube-c73e83da283c6d4eb094e384d59c4f8eb221507d.tar.zst PeerTube-c73e83da283c6d4eb094e384d59c4f8eb221507d.zip |
Truncate correctly video descriptions
Diffstat (limited to 'server/helpers/custom-validators/activitypub')
-rw-r--r-- | server/helpers/custom-validators/activitypub/videos.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index 10588423a..3af587a32 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import * as validator from 'validator' | 1 | import * as validator from 'validator' |
2 | import { ACTIVITY_PUB } from '../../../initializers' | 2 | import { ACTIVITY_PUB, CONSTRAINTS_FIELDS } from '../../../initializers' |
3 | import { peertubeTruncate } from '../../core-utils' | ||
3 | import { exists, isBooleanValid, isDateValid, isUUIDValid } from '../misc' | 4 | import { exists, isBooleanValid, isDateValid, isUUIDValid } from '../misc' |
4 | import { | 5 | import { |
5 | isVideoAbuseReasonValid, | 6 | isVideoAbuseReasonValid, |
@@ -56,6 +57,7 @@ function isVideoTorrentObjectValid (video: any) { | |||
56 | isBooleanValid(video.commentsEnabled) && | 57 | isBooleanValid(video.commentsEnabled) && |
57 | isDateValid(video.published) && | 58 | isDateValid(video.published) && |
58 | isDateValid(video.updated) && | 59 | isDateValid(video.updated) && |
60 | setTruncatedContent(video) && | ||
59 | (!video.content || isRemoteVideoContentValid(video.mediaType, video.content)) && | 61 | (!video.content || isRemoteVideoContentValid(video.mediaType, video.content)) && |
60 | isRemoteVideoIconValid(video.icon) && | 62 | isRemoteVideoIconValid(video.icon) && |
61 | setValidRemoteVideoUrls(video) && | 63 | setValidRemoteVideoUrls(video) && |
@@ -111,6 +113,14 @@ function setValidRemoteVideoUrls (video: any) { | |||
111 | return true | 113 | return true |
112 | } | 114 | } |
113 | 115 | ||
116 | function setTruncatedContent (video: any) { | ||
117 | if (video.content) { | ||
118 | video.content = peertubeTruncate(video.content, CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max) | ||
119 | } | ||
120 | |||
121 | return true | ||
122 | } | ||
123 | |||
114 | function isRemoteVideoUrlValid (url: any) { | 124 | function isRemoteVideoUrlValid (url: any) { |
115 | return url.type === 'Link' && | 125 | return url.type === 'Link' && |
116 | ( | 126 | ( |