mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-06 03:50:26 +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
|
@ -4,7 +4,7 @@ import { openapiOperationDoc } from '@server/middlewares/doc.js'
|
|||
import { getServerActor } from '@server/models/application/application.js'
|
||||
import express from 'express'
|
||||
import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger.js'
|
||||
import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils.js'
|
||||
import { buildNSFWFilters, getCountVideos } from '../../../helpers/express-utils.js'
|
||||
import { logger } from '../../../helpers/logger.js'
|
||||
import { getFormattedObjects } from '../../../helpers/utils.js'
|
||||
import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../initializers/constants.js'
|
||||
|
@ -73,24 +73,13 @@ videosRouter.use('/', storyboardRouter)
|
|||
videosRouter.use('/', videoSourceRouter)
|
||||
videosRouter.use('/', videoChaptersRouter)
|
||||
|
||||
videosRouter.get('/categories',
|
||||
openapiOperationDoc({ operationId: 'getCategories' }),
|
||||
listVideoCategories
|
||||
)
|
||||
videosRouter.get('/licences',
|
||||
openapiOperationDoc({ operationId: 'getLicences' }),
|
||||
listVideoLicences
|
||||
)
|
||||
videosRouter.get('/languages',
|
||||
openapiOperationDoc({ operationId: 'getLanguages' }),
|
||||
listVideoLanguages
|
||||
)
|
||||
videosRouter.get('/privacies',
|
||||
openapiOperationDoc({ operationId: 'getPrivacies' }),
|
||||
listVideoPrivacies
|
||||
)
|
||||
videosRouter.get('/categories', openapiOperationDoc({ operationId: 'getCategories' }), listVideoCategories)
|
||||
videosRouter.get('/licences', openapiOperationDoc({ operationId: 'getLicences' }), listVideoLicences)
|
||||
videosRouter.get('/languages', openapiOperationDoc({ operationId: 'getLanguages' }), listVideoLanguages)
|
||||
videosRouter.get('/privacies', openapiOperationDoc({ operationId: 'getPrivacies' }), listVideoPrivacies)
|
||||
|
||||
videosRouter.get('/',
|
||||
videosRouter.get(
|
||||
'/',
|
||||
openapiOperationDoc({ operationId: 'getVideos' }),
|
||||
paginationValidator,
|
||||
videosSortValidator,
|
||||
|
@ -101,7 +90,8 @@ videosRouter.get('/',
|
|||
asyncMiddleware(listVideos)
|
||||
)
|
||||
|
||||
videosRouter.get('/:id',
|
||||
videosRouter.get(
|
||||
'/:id',
|
||||
openapiOperationDoc({ operationId: 'getVideo' }),
|
||||
optionalAuthenticate,
|
||||
asyncMiddleware(videosCustomGetValidator('for-api')),
|
||||
|
@ -109,7 +99,8 @@ videosRouter.get('/:id',
|
|||
asyncMiddleware(getVideo)
|
||||
)
|
||||
|
||||
videosRouter.delete('/:id',
|
||||
videosRouter.delete(
|
||||
'/:id',
|
||||
openapiOperationDoc({ operationId: 'delVideo' }),
|
||||
authenticate,
|
||||
asyncMiddleware(videosRemoveValidator),
|
||||
|
@ -163,12 +154,12 @@ async function listVideos (req: express.Request, res: express.Response) {
|
|||
|
||||
const apiOptions = await Hooks.wrapObject({
|
||||
...query,
|
||||
...buildNSFWFilters({ req, res }),
|
||||
|
||||
displayOnlyForFollower: {
|
||||
actorId: serverActor.id,
|
||||
orLocalVideos: true
|
||||
},
|
||||
nsfw: buildNSFWFilter(res, query.nsfw),
|
||||
user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
|
||||
countVideos
|
||||
}, 'filter:api.videos.list.params')
|
||||
|
@ -195,6 +186,6 @@ async function removeVideo (req: express.Request, res: express.Response) {
|
|||
Hooks.runAction('action:api.video.deleted', { video: videoInstance, req, res })
|
||||
|
||||
return res.type('json')
|
||||
.status(HttpStatusCode.NO_CONTENT_204)
|
||||
.end()
|
||||
.status(HttpStatusCode.NO_CONTENT_204)
|
||||
.end()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue