mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +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
|
@ -1,12 +1,12 @@
|
|||
import 'multer'
|
||||
import express from 'express'
|
||||
import { HttpStatusCode } from '@peertube/peertube-models'
|
||||
import { handlesToNameAndHost } from '@server/helpers/actors.js'
|
||||
import { pickCommonVideoQuery } from '@server/helpers/query.js'
|
||||
import { sendUndoFollow } from '@server/lib/activitypub/send/index.js'
|
||||
import { Hooks } from '@server/lib/plugins/hooks.js'
|
||||
import { VideoChannelModel } from '@server/models/video/video-channel.js'
|
||||
import { buildNSFWFilter, getCountVideos } from '../../../helpers/express-utils.js'
|
||||
import express from 'express'
|
||||
import 'multer'
|
||||
import { buildNSFWFilters, getCountVideos } from '../../../helpers/express-utils.js'
|
||||
import { getFormattedObjects } from '../../../helpers/utils.js'
|
||||
import { sequelizeTypescript } from '../../../initializers/database.js'
|
||||
import { JobQueue } from '../../../lib/job-queue/index.js'
|
||||
|
@ -34,7 +34,8 @@ import { VideoModel } from '../../../models/video/video.js'
|
|||
|
||||
const mySubscriptionsRouter = express.Router()
|
||||
|
||||
mySubscriptionsRouter.get('/me/subscriptions/videos',
|
||||
mySubscriptionsRouter.get(
|
||||
'/me/subscriptions/videos',
|
||||
authenticate,
|
||||
paginationValidator,
|
||||
videosSortValidator,
|
||||
|
@ -44,13 +45,10 @@ mySubscriptionsRouter.get('/me/subscriptions/videos',
|
|||
asyncMiddleware(getUserSubscriptionVideos)
|
||||
)
|
||||
|
||||
mySubscriptionsRouter.get('/me/subscriptions/exist',
|
||||
authenticate,
|
||||
areSubscriptionsExistValidator,
|
||||
asyncMiddleware(areSubscriptionsExist)
|
||||
)
|
||||
mySubscriptionsRouter.get('/me/subscriptions/exist', authenticate, areSubscriptionsExistValidator, asyncMiddleware(areSubscriptionsExist))
|
||||
|
||||
mySubscriptionsRouter.get('/me/subscriptions',
|
||||
mySubscriptionsRouter.get(
|
||||
'/me/subscriptions',
|
||||
authenticate,
|
||||
paginationValidator,
|
||||
userSubscriptionsSortValidator,
|
||||
|
@ -60,19 +58,12 @@ mySubscriptionsRouter.get('/me/subscriptions',
|
|||
asyncMiddleware(listUserSubscriptions)
|
||||
)
|
||||
|
||||
mySubscriptionsRouter.post('/me/subscriptions',
|
||||
authenticate,
|
||||
userSubscriptionAddValidator,
|
||||
addUserSubscription
|
||||
)
|
||||
mySubscriptionsRouter.post('/me/subscriptions', authenticate, userSubscriptionAddValidator, addUserSubscription)
|
||||
|
||||
mySubscriptionsRouter.get('/me/subscriptions/:uri',
|
||||
authenticate,
|
||||
userSubscriptionGetValidator,
|
||||
asyncMiddleware(getUserSubscription)
|
||||
)
|
||||
mySubscriptionsRouter.get('/me/subscriptions/:uri', authenticate, userSubscriptionGetValidator, asyncMiddleware(getUserSubscription))
|
||||
|
||||
mySubscriptionsRouter.delete('/me/subscriptions/:uri',
|
||||
mySubscriptionsRouter.delete(
|
||||
'/me/subscriptions/:uri',
|
||||
authenticate,
|
||||
userSubscriptionGetValidator,
|
||||
asyncRetryTransactionMiddleware(deleteUserSubscription)
|
||||
|
@ -94,7 +85,7 @@ async function areSubscriptionsExist (req: express.Request, res: express.Respons
|
|||
|
||||
const results = await ActorFollowModel.listSubscriptionsOf(user.Account.Actor.id, sanitizedHandles)
|
||||
|
||||
const existObject: { [id: string ]: boolean } = {}
|
||||
const existObject: { [id: string]: boolean } = {}
|
||||
for (const sanitizedHandle of sanitizedHandles) {
|
||||
const obj = results.find(r => {
|
||||
const server = r.ActorFollowing.Server
|
||||
|
@ -147,8 +138,8 @@ async function deleteUserSubscription (req: express.Request, res: express.Respon
|
|||
})
|
||||
|
||||
return res.type('json')
|
||||
.status(HttpStatusCode.NO_CONTENT_204)
|
||||
.end()
|
||||
.status(HttpStatusCode.NO_CONTENT_204)
|
||||
.end()
|
||||
}
|
||||
|
||||
async function listUserSubscriptions (req: express.Request, res: express.Response) {
|
||||
|
@ -173,12 +164,12 @@ async function getUserSubscriptionVideos (req: express.Request, res: express.Res
|
|||
|
||||
const apiOptions = await Hooks.wrapObject({
|
||||
...query,
|
||||
...buildNSFWFilters({ req, res }),
|
||||
|
||||
displayOnlyForFollower: {
|
||||
actorId: user.Account.Actor.id,
|
||||
orLocalVideos: false
|
||||
},
|
||||
nsfw: buildNSFWFilter(res, query.nsfw),
|
||||
user,
|
||||
countVideos
|
||||
}, 'filter:api.user.me.subscription-videos.list.params')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue