mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
Improve NSFW system
* Add NSFW flags to videos so the publisher can add more NSFW context * Add NSFW summary to videos, similar to content warning system so the publisher has a free text to describe NSFW aspect of its video * Add additional "warn" NSFW policy: the video thumbnail is not blurred and we display a tag below the video miniature, the video player includes the NSFW warning (with context if available) and it also prevent autoplay * "blur" NSFW settings inherits "warn" policy and also blur the video thumbnail * Add NSFW flag settings to users so they can have more granular control about what content they want to hide, warn or display
This commit is contained in:
parent
fac6b15ada
commit
dd4027a10f
181 changed files with 5081 additions and 2061 deletions
|
@ -155,7 +155,10 @@ export function isAPCaptionUrlObject (url: any): url is ActivityCaptionUrlObject
|
|||
function setValidRemoteTags (video: VideoObject) {
|
||||
if (Array.isArray(video.tag) === false) video.tag = []
|
||||
|
||||
video.tag = video.tag.filter(t => t.type === 'Hashtag' && isVideoTagValid(t.name))
|
||||
video.tag = video.tag.filter(t => {
|
||||
return (t.type === 'Hashtag' && isVideoTagValid(t.name)) ||
|
||||
(t.type === 'SensitiveTag' && !!t.name)
|
||||
})
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -98,8 +98,8 @@ export function isVideoFileMimeTypeValid (files: UploadFilesForCheck, field = 'v
|
|||
}
|
||||
|
||||
const videoImageTypes = CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME
|
||||
.map(v => v.replace('.', ''))
|
||||
.join('|')
|
||||
.map(v => v.replace('.', ''))
|
||||
.join('|')
|
||||
const videoImageTypesRegex = `image/(${videoImageTypes})`
|
||||
|
||||
export function isVideoImageValid (files: UploadFilesForCheck, field: string, optional = true) {
|
||||
|
@ -193,3 +193,11 @@ export function isValidPasswordProtectedPrivacy (req: Request, res: Response) {
|
|||
|
||||
return true
|
||||
}
|
||||
|
||||
export function isNSFWFlagsValid (value: number) {
|
||||
return value === null || (exists(value) && validator.default.isInt('' + value))
|
||||
}
|
||||
|
||||
export function isNSFWSummaryValid (value: any) {
|
||||
return value === null || (exists(value) && validator.default.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.NSFW_SUMMARY))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue