1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 09:49:20 +02:00

Add ability to disable NSFW flags settings

This commit is contained in:
Chocobozzz 2025-05-12 10:18:55 +02:00
parent 9f180a36c4
commit dc05b37d17
No known key found for this signature in database
GPG key ID: 583A612D890159BE
12 changed files with 867 additions and 323 deletions

View file

@ -1,42 +1,61 @@
<form (ngSubmit)="updateDetails()" [formGroup]="form"> <form (ngSubmit)="updateDetails()" [formGroup]="form">
<div class="form-group"> <div class="form-group">
<div class="anchor" id="video-sensitive-content-policy"></div> <!-- video-sensitive-content-policy anchor --> <div class="anchor" id="video-sensitive-content-policy"></div>
<!-- video-sensitive-content-policy anchor -->
<div class="form-group"> <div class="form-group">
<my-select-radio <my-select-radio
[items]="nsfwItems" inputId="nsfwPolicy" isGroup="true" [items]="nsfwItems"
i18n-label label="Policy on videos containing sensitive content" inputId="nsfwPolicy"
isGroup="true"
i18n-label
label="Policy on videos containing sensitive content"
formControlName="nsfwPolicy" formControlName="nsfwPolicy"
></my-select-radio> ></my-select-radio>
</div> </div>
<div class="form-group mb-3"> @if (isNsfwFlagsEnabled()) {
<my-select-radio <div class="form-group mb-3">
[items]="nsfwFlagItems" inputId="nsfwFlagViolent" isGroup="true" <my-select-radio
labelSecondary="true" i18n-label label="Redefine policy for violent content" [items]="nsfwFlagItems"
formControlName="nsfwFlagViolent" inputId="nsfwFlagViolent"
></my-select-radio> isGroup="true"
</div> labelSecondary="true"
i18n-label
label="Redefine policy for violent content"
formControlName="nsfwFlagViolent"
></my-select-radio>
</div>
<div class="form-group mb-3"> <div class="form-group mb-3">
<my-select-radio <my-select-radio
[items]="nsfwFlagItems" inputId="nsfwFlagShocking" isGroup="true" [items]="nsfwFlagItems"
labelSecondary="true" i18n-label label="Redefine policy for shocking or disturbing content" inputId="nsfwFlagShocking"
formControlName="nsfwFlagShocking" isGroup="true"
></my-select-radio> labelSecondary="true"
</div> i18n-label
label="Redefine policy for shocking or disturbing content"
formControlName="nsfwFlagShocking"
></my-select-radio>
</div>
<div class="form-group mb-3"> <div class="form-group mb-3">
<my-select-radio <my-select-radio
[items]="nsfwFlagItems" inputId="nsfwFlagSex" isGroup="true" [items]="nsfwFlagItems"
labelSecondary="true" i18n-label label="Redefine policy for sexually explicit material" inputId="nsfwFlagSex"
formControlName="nsfwFlagSex" isGroup="true"
></my-select-radio> labelSecondary="true"
</div> i18n-label
label="Redefine policy for sexually explicit material"
formControlName="nsfwFlagSex"
></my-select-radio>
</div>
}
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="anchor" id="video-languages-subtitles"></div> <!-- video-languages-subtitles anchor --> <div class="anchor" id="video-languages-subtitles"></div>
<!-- video-languages-subtitles anchor -->
<div class="pt-label-container"> <div class="pt-label-container">
<label i18n for="videoLanguages">Only display videos in the following languages/subtitles</label> <label i18n for="videoLanguages">Only display videos in the following languages/subtitles</label>
@ -53,21 +72,18 @@
<ng-content select="inner-title"></ng-content> <ng-content select="inner-title"></ng-content>
<div class="form-group"> <div class="form-group">
<my-peertube-checkbox <my-peertube-checkbox inputName="p2pEnabled" formControlName="p2pEnabled" [recommended]="true" i18n-labelText labelText="Help share videos being played">
inputName="p2pEnabled" formControlName="p2pEnabled" [recommended]="true"
i18n-labelText labelText="Help share videos being played"
>
<ng-container ngProjectAs="description"> <ng-container ngProjectAs="description">
<span i18n>The <a class="link-primary" href="https://docs.joinpeertube.org/admin/privacy-guide#peertube-p2p-privacy" target="_blank">sharing system</a> implies that some technical information about your system (such as a public IP address) can be sent to other peers, but greatly helps to reduce server load.</span> <span i18n
>The <a class="link-primary" href="https://docs.joinpeertube.org/admin/privacy-guide#peertube-p2p-privacy" target="_blank">sharing system</a> implies
that some technical information about your system (such as a public IP address) can be sent to other peers, but greatly helps to reduce server
load.</span>
</ng-container> </ng-container>
</my-peertube-checkbox> </my-peertube-checkbox>
</div> </div>
<div class="form-group"> <div class="form-group">
<my-peertube-checkbox <my-peertube-checkbox inputName="autoPlayVideo" formControlName="autoPlayVideo" i18n-labelText labelText="Automatically play videos">
inputName="autoPlayVideo" formControlName="autoPlayVideo"
i18n-labelText labelText="Automatically play videos"
>
<ng-container ngProjectAs="description"> <ng-container ngProjectAs="description">
<span i18n>When on a video page, directly start playing the video.</span> <span i18n>When on a video page, directly start playing the video.</span>
</ng-container> </ng-container>
@ -76,8 +92,10 @@
<div class="form-group"> <div class="form-group">
<my-peertube-checkbox <my-peertube-checkbox
inputName="autoPlayNextVideo" formControlName="autoPlayNextVideo" inputName="autoPlayNextVideo"
i18n-labelText labelText="Automatically start playing the next video" formControlName="autoPlayNextVideo"
i18n-labelText
labelText="Automatically start playing the next video"
> >
<ng-container ngProjectAs="description"> <ng-container ngProjectAs="description">
<span i18n>When a video ends, follow up with the next suggested video.</span> <span i18n>When a video ends, follow up with the next suggested video.</span>

View file

@ -204,6 +204,10 @@ export class UserVideoSettingsComponent implements OnInit, OnDestroy {
return this.updateAnonymousProfile(details) return this.updateAnonymousProfile(details)
} }
isNsfwFlagsEnabled () {
return this.serverService.getHTMLConfig().nsfwFlagsSettings.enabled
}
private handleReactiveUpdate () { private handleReactiveUpdate () {
let oldForm = { ...this.form.value } let oldForm = { ...this.form.value }

View file

@ -533,6 +533,11 @@ webrtc:
- 'stun:stunserver2024.stunprotocol.org' - 'stun:stunserver2024.stunprotocol.org'
- 'stun:stun.framasoft.org' - 'stun:stun.framasoft.org'
nsfw_flags_settings:
# Allow logged-in/anonymous users to have a more granular control over their NSFW policy
# using NSFW flags (violent content, etc.) set by video authors
enabled: true
cache: cache:
previews: previews:
size: 500 # Max number of previews you want to cache size: 500 # Max number of previews you want to cache

View file

@ -531,6 +531,11 @@ webrtc:
- 'stun:stunserver2024.stunprotocol.org' - 'stun:stunserver2024.stunprotocol.org'
- 'stun:stun.framasoft.org' - 'stun:stun.framasoft.org'
nsfw_flags_settings:
# Allow logged-in/anonymous users to have a more granular control over their NSFW policy
# using NSFW flags (violent content, etc.) set by video authors
enabled: false
############################################################################### ###############################################################################
# #
# From this point, almost all following keys can be overridden by the web interface # From this point, almost all following keys can be overridden by the web interface
@ -1087,6 +1092,11 @@ client:
# You can automatically redirect your users on this external platform when they click on the login button # You can automatically redirect your users on this external platform when they click on the login button
redirect_on_single_external_auth: false redirect_on_single_external_auth: false
# Allow logged-in/anonymous users to have a more granular control over their NSFW policy
# using NSFW flags (violent content, etc.) set by video authors
nsfw_flags_settings:
enabled: true
open_in_app: open_in_app:
android: android:
# Use an intent URL: https://developer.chrome.com/docs/android/intents # Use an intent URL: https://developer.chrome.com/docs/android/intents

View file

@ -399,6 +399,10 @@ export interface ServerConfig {
webrtc: { webrtc: {
stunServers: string[] stunServers: string[]
} }
nsfwFlagsSettings: {
enabled: boolean
}
} }
export type HTMLServerConfig = Omit<ServerConfig, 'signup'> export type HTMLServerConfig = Omit<ServerConfig, 'signup'>

View file

@ -549,6 +549,34 @@ describe('Test video NSFW policy', function () {
expect(data.map(v => v.name)).to.have.members([ 'not nsfw', 'nsfw simple', 'nsfw sex', 'import violent', 'live violent' ]) expect(data.map(v => v.name)).to.have.members([ 'not nsfw', 'nsfw simple', 'nsfw sex', 'import violent', 'live violent' ])
} }
}) })
it('Should disable NSFW flags policy', async function () {
await servers[0].users.updateMe({
token: userAccessToken,
nsfwPolicy: 'do_not_list',
nsfwFlagsHidden: NSFWFlag.EXPLICIT_SEX,
nsfwFlagsWarned: NSFWFlag.NONE,
nsfwFlagsBlurred: NSFWFlag.SHOCKING_DISTURBING,
nsfwFlagsDisplayed: NSFWFlag.VIOLENT
})
await servers[0].kill()
await servers[0].run({ nsfw_flags_settings: { enabled: false } })
const me = await servers[0].users.getMyInfo({ token: userAccessToken })
expect(me.nsfwPolicy).to.equal('do_not_list')
expect(me.nsfwFlagsHidden).to.equal(0)
expect(me.nsfwFlagsWarned).to.equal(0)
expect(me.nsfwFlagsBlurred).to.equal(0)
expect(me.nsfwFlagsDisplayed).to.equal(0)
for (const { total, data } of await getVideosFunctions(userAccessToken)) {
expect(total).to.equal(1)
expect(data).to.have.lengthOf(1)
expect(data.map(v => v.name)).to.have.members([ 'not nsfw' ])
}
})
}) })
after(async function () { after(async function () {

View file

@ -31,24 +31,20 @@ configRouter.use(apiRateLimiter)
const auditLogger = auditLoggerFactory('config') const auditLogger = auditLoggerFactory('config')
configRouter.get('/', configRouter.get('/', openapiOperationDoc({ operationId: 'getConfig' }), asyncMiddleware(getConfig))
openapiOperationDoc({ operationId: 'getConfig' }),
asyncMiddleware(getConfig)
)
configRouter.get('/about', configRouter.get('/about', openapiOperationDoc({ operationId: 'getAbout' }), asyncMiddleware(getAbout))
openapiOperationDoc({ operationId: 'getAbout' }),
asyncMiddleware(getAbout)
)
configRouter.get('/custom', configRouter.get(
'/custom',
openapiOperationDoc({ operationId: 'getCustomConfig' }), openapiOperationDoc({ operationId: 'getCustomConfig' }),
authenticate, authenticate,
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
getCustomConfig getCustomConfig
) )
configRouter.put('/custom', configRouter.put(
'/custom',
openapiOperationDoc({ operationId: 'putCustomConfig' }), openapiOperationDoc({ operationId: 'putCustomConfig' }),
authenticate, authenticate,
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
@ -57,7 +53,8 @@ configRouter.put('/custom',
asyncMiddleware(updateCustomConfig) asyncMiddleware(updateCustomConfig)
) )
configRouter.delete('/custom', configRouter.delete(
'/custom',
openapiOperationDoc({ operationId: 'delCustomConfig' }), openapiOperationDoc({ operationId: 'delCustomConfig' }),
authenticate, authenticate,
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
@ -67,7 +64,8 @@ configRouter.delete('/custom',
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
configRouter.post('/instance-banner/pick', configRouter.post(
'/instance-banner/pick',
authenticate, authenticate,
createReqFiles([ 'bannerfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT), createReqFiles([ 'bannerfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT),
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
@ -75,7 +73,8 @@ configRouter.post('/instance-banner/pick',
asyncMiddleware(updateInstanceImageFactory(ActorImageType.BANNER)) asyncMiddleware(updateInstanceImageFactory(ActorImageType.BANNER))
) )
configRouter.delete('/instance-banner', configRouter.delete(
'/instance-banner',
authenticate, authenticate,
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
asyncMiddleware(deleteInstanceImageFactory(ActorImageType.BANNER)) asyncMiddleware(deleteInstanceImageFactory(ActorImageType.BANNER))
@ -83,7 +82,8 @@ configRouter.delete('/instance-banner',
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
configRouter.post('/instance-avatar/pick', configRouter.post(
'/instance-avatar/pick',
authenticate, authenticate,
createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT), createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT),
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
@ -91,7 +91,8 @@ configRouter.post('/instance-avatar/pick',
asyncMiddleware(updateInstanceImageFactory(ActorImageType.AVATAR)) asyncMiddleware(updateInstanceImageFactory(ActorImageType.AVATAR))
) )
configRouter.delete('/instance-avatar', configRouter.delete(
'/instance-avatar',
authenticate, authenticate,
ensureUserHasRight(UserRight.MANAGE_CONFIGURATION), ensureUserHasRight(UserRight.MANAGE_CONFIGURATION),
asyncMiddleware(deleteInstanceImageFactory(ActorImageType.AVATAR)) asyncMiddleware(deleteInstanceImageFactory(ActorImageType.AVATAR))

View file

@ -1,4 +1,4 @@
import { VideosCommonQuery } from '@peertube/peertube-models' import { NSFWFlag, VideosCommonQuery } from '@peertube/peertube-models'
import { getLowercaseExtension } from '@peertube/peertube-node-utils' import { getLowercaseExtension } from '@peertube/peertube-node-utils'
import express, { RequestHandler } from 'express' import express, { RequestHandler } from 'express'
import multer, { diskStorage } from 'multer' import multer, { diskStorage } from 'multer'
@ -19,8 +19,14 @@ export function buildNSFWFilters (options: {
} = {}) { } = {}) {
return { return {
nsfw: buildNSFWFilter(options), nsfw: buildNSFWFilter(options),
nsfwFlagsIncluded: buildNSFWFlagsIncluded(options),
nsfwFlagsExcluded: buildNSFWFlagsExcluded(options) nsfwFlagsIncluded: CONFIG.NSFW_FLAGS_SETTINGS.ENABLED
? buildNSFWFlagsIncluded(options)
: NSFWFlag.NONE,
nsfwFlagsExcluded: CONFIG.NSFW_FLAGS_SETTINGS.ENABLED
? buildNSFWFlagsExcluded(options)
: NSFWFlag.NONE
} }
} }

View file

@ -6,92 +6,250 @@ import { logger } from '../helpers/logger.js'
// ONLY USE CORE MODULES IN THIS FILE! // ONLY USE CORE MODULES IN THIS FILE!
// Check the config files // Check the config files
function checkMissedConfig () { export function checkMissedConfig () {
const required = [ 'listen.port', 'listen.hostname', const required = [
'webserver.https', 'webserver.hostname', 'webserver.port', 'listen.port',
'listen.hostname',
'webserver.https',
'webserver.hostname',
'webserver.port',
'secrets.peertube', 'secrets.peertube',
'trust_proxy', 'trust_proxy',
'oauth2.token_lifetime.access_token', 'oauth2.token_lifetime.refresh_token', 'oauth2.token_lifetime.access_token',
'database.hostname', 'database.port', 'database.username', 'database.password', 'database.pool.max', 'oauth2.token_lifetime.refresh_token',
'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address', 'database.hostname',
'email.body.signature', 'email.subject.prefix', 'database.port',
'storage.avatars', 'storage.web_videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', 'database.username',
'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists', 'storage.plugins', 'storage.well_known', 'database.password',
'log.level', 'log.rotation.enabled', 'log.rotation.max_file_size', 'log.rotation.max_files', 'log.anonymize_ip', 'database.pool.max',
'log.log_ping_requests', 'log.log_tracker_unknown_infohash', 'log.prettify_sql', 'log.accept_client_log', 'smtp.hostname',
'open_telemetry.metrics.enabled', 'open_telemetry.metrics.playback_stats_interval', 'smtp.port',
'open_telemetry.metrics.prometheus_exporter.hostname', 'open_telemetry.metrics.prometheus_exporter.port', 'smtp.username',
'open_telemetry.tracing.enabled', 'open_telemetry.tracing.jaeger_exporter.endpoint', 'smtp.password',
'smtp.tls',
'smtp.from_address',
'email.body.signature',
'email.subject.prefix',
'storage.avatars',
'storage.web_videos',
'storage.logs',
'storage.previews',
'storage.thumbnails',
'storage.torrents',
'storage.cache',
'storage.redundancy',
'storage.tmp',
'storage.streaming_playlists',
'storage.plugins',
'storage.well_known',
'log.level',
'log.rotation.enabled',
'log.rotation.max_file_size',
'log.rotation.max_files',
'log.anonymize_ip',
'log.log_ping_requests',
'log.log_tracker_unknown_infohash',
'log.prettify_sql',
'log.accept_client_log',
'open_telemetry.metrics.enabled',
'open_telemetry.metrics.playback_stats_interval',
'open_telemetry.metrics.prometheus_exporter.hostname',
'open_telemetry.metrics.prometheus_exporter.port',
'open_telemetry.tracing.enabled',
'open_telemetry.tracing.jaeger_exporter.endpoint',
'open_telemetry.metrics.http_request_duration.enabled', 'open_telemetry.metrics.http_request_duration.enabled',
'user.history.videos.enabled', 'user.video_quota', 'user.video_quota_daily', 'user.history.videos.enabled',
'user.video_quota',
'user.video_quota_daily',
'video_channels.max_per_user', 'video_channels.max_per_user',
'csp.enabled', 'csp.report_only', 'csp.report_uri', 'csp.enabled',
'security.frameguard.enabled', 'security.powered_by_header.enabled', 'csp.report_only',
'cache.previews.size', 'cache.captions.size', 'cache.torrents.size', 'cache.storyboards.size', 'csp.report_uri',
'admin.email', 'contact_form.enabled', 'security.frameguard.enabled',
'signup.enabled', 'signup.limit', 'signup.requires_approval', 'signup.requires_email_verification', 'signup.minimum_age', 'security.powered_by_header.enabled',
'signup.filters.cidr.whitelist', 'signup.filters.cidr.blacklist', 'cache.previews.size',
'redundancy.videos.strategies', 'redundancy.videos.check_interval', 'cache.captions.size',
'transcoding.enabled', 'transcoding.original_file.keep', 'transcoding.threads', 'transcoding.allow_additional_extensions', 'cache.torrents.size',
'transcoding.web_videos.enabled', 'transcoding.hls.enabled', 'transcoding.profile', 'transcoding.concurrency', 'cache.storyboards.size',
'transcoding.resolutions.0p', 'transcoding.resolutions.144p', 'transcoding.resolutions.240p', 'transcoding.resolutions.360p', 'admin.email',
'transcoding.resolutions.480p', 'transcoding.resolutions.720p', 'transcoding.resolutions.1080p', 'transcoding.resolutions.1440p', 'contact_form.enabled',
'transcoding.resolutions.2160p', 'transcoding.always_transcode_original_resolution', 'transcoding.remote_runners.enabled', 'signup.enabled',
'signup.limit',
'signup.requires_approval',
'signup.requires_email_verification',
'signup.minimum_age',
'signup.filters.cidr.whitelist',
'signup.filters.cidr.blacklist',
'redundancy.videos.strategies',
'redundancy.videos.check_interval',
'transcoding.enabled',
'transcoding.original_file.keep',
'transcoding.threads',
'transcoding.allow_additional_extensions',
'transcoding.web_videos.enabled',
'transcoding.hls.enabled',
'transcoding.profile',
'transcoding.concurrency',
'transcoding.resolutions.0p',
'transcoding.resolutions.144p',
'transcoding.resolutions.240p',
'transcoding.resolutions.360p',
'transcoding.resolutions.480p',
'transcoding.resolutions.720p',
'transcoding.resolutions.1080p',
'transcoding.resolutions.1440p',
'transcoding.resolutions.2160p',
'transcoding.always_transcode_original_resolution',
'transcoding.remote_runners.enabled',
'transcoding.fps.max', 'transcoding.fps.max',
'video_studio.enabled', 'video_studio.remote_runners.enabled', 'video_studio.enabled',
'video_studio.remote_runners.enabled',
'video_file.update.enabled', 'video_file.update.enabled',
'remote_runners.stalled_jobs.vod', 'remote_runners.stalled_jobs.live', 'remote_runners.stalled_jobs.vod',
'thumbnails.generation_from_video.frames_to_analyze', 'thumbnails.sizes', 'remote_runners.stalled_jobs.live',
'import.videos.http.enabled', 'import.videos.torrent.enabled', 'import.videos.concurrency', 'import.videos.timeout', 'thumbnails.generation_from_video.frames_to_analyze',
'import.videos.http.force_ipv4', 'import.videos.http.proxies', 'thumbnails.sizes',
'import.video_channel_synchronization.enabled', 'import.video_channel_synchronization.max_per_user', 'import.videos.http.enabled',
'import.video_channel_synchronization.check_interval', 'import.video_channel_synchronization.videos_limit_per_synchronization', 'import.videos.torrent.enabled',
'import.videos.concurrency',
'import.videos.timeout',
'import.videos.http.force_ipv4',
'import.videos.http.proxies',
'import.video_channel_synchronization.enabled',
'import.video_channel_synchronization.max_per_user',
'import.video_channel_synchronization.check_interval',
'import.video_channel_synchronization.videos_limit_per_synchronization',
'import.video_channel_synchronization.full_sync_videos_limit', 'import.video_channel_synchronization.full_sync_videos_limit',
'auto_blacklist.videos.of_users.enabled', 'trending.videos.interval_days', 'auto_blacklist.videos.of_users.enabled',
'client.videos.miniature.prefer_author_display_name', 'client.menu.login.redirect_on_single_external_auth', 'trending.videos.interval_days',
'defaults.publish.download_enabled', 'defaults.publish.comments_policy', 'defaults.publish.privacy', 'defaults.publish.licence', 'client.videos.miniature.prefer_author_display_name',
'client.menu.login.redirect_on_single_external_auth',
'defaults.publish.download_enabled',
'defaults.publish.comments_policy',
'defaults.publish.privacy',
'defaults.publish.licence',
'defaults.player.auto_play', 'defaults.player.auto_play',
'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route', 'instance.name',
'instance.is_nsfw', 'instance.default_nsfw_policy', 'instance.robots', 'instance.securitytxt', 'instance.short_description',
'instance.server_country', 'instance.support.text', 'instance.social.external_link', 'instance.social.mastodon_link', 'instance.description',
'instance.terms',
'instance.default_client_route',
'instance.is_nsfw',
'instance.default_nsfw_policy',
'instance.robots',
'instance.securitytxt',
'instance.server_country',
'instance.support.text',
'instance.social.external_link',
'instance.social.mastodon_link',
'instance.social.bluesky_link', 'instance.social.bluesky_link',
'services.twitter.username', 'services.twitter.username',
'followers.instance.enabled', 'followers.instance.manual_approval', 'followers.instance.enabled',
'tracker.enabled', 'tracker.private', 'tracker.reject_too_many_announces', 'followers.instance.manual_approval',
'history.videos.max_age', 'views.videos.remote.max_age', 'views.videos.local_buffer_update_interval', 'views.videos.view_expiration', 'tracker.enabled',
'views.videos.watching_interval.anonymous', 'views.videos.watching_interval.users', 'tracker.private',
'rates_limit.api.window', 'rates_limit.api.max', 'rates_limit.login.window', 'rates_limit.login.max', 'tracker.reject_too_many_announces',
'rates_limit.signup.window', 'rates_limit.signup.max', 'rates_limit.ask_send_email.window', 'rates_limit.ask_send_email.max', 'history.videos.max_age',
'rates_limit.receive_client_log.window', 'rates_limit.receive_client_log.max', 'rates_limit.plugins.window', 'rates_limit.plugins.max', 'views.videos.remote.max_age',
'rates_limit.well_known.window', 'rates_limit.well_known.max', 'rates_limit.feeds.window', 'rates_limit.feeds.max', 'views.videos.local_buffer_update_interval',
'rates_limit.activity_pub.window', 'rates_limit.activity_pub.max', 'rates_limit.client.window', 'rates_limit.client.max', 'views.videos.view_expiration',
'views.videos.watching_interval.anonymous',
'views.videos.watching_interval.users',
'rates_limit.api.window',
'rates_limit.api.max',
'rates_limit.login.window',
'rates_limit.login.max',
'rates_limit.signup.window',
'rates_limit.signup.max',
'rates_limit.ask_send_email.window',
'rates_limit.ask_send_email.max',
'rates_limit.receive_client_log.window',
'rates_limit.receive_client_log.max',
'rates_limit.plugins.window',
'rates_limit.plugins.max',
'rates_limit.well_known.window',
'rates_limit.well_known.max',
'rates_limit.feeds.window',
'rates_limit.feeds.max',
'rates_limit.activity_pub.window',
'rates_limit.activity_pub.max',
'rates_limit.client.window',
'rates_limit.client.max',
'static_files.private_files_require_auth', 'static_files.private_files_require_auth',
'object_storage.enabled', 'object_storage.endpoint', 'object_storage.region', 'object_storage.upload_acl.public', 'object_storage.enabled',
'object_storage.upload_acl.private', 'object_storage.proxy.proxify_private_files', 'object_storage.credentials.access_key_id', 'object_storage.endpoint',
'object_storage.credentials.secret_access_key', 'object_storage.max_upload_part', 'object_storage.streaming_playlists.bucket_name', 'object_storage.region',
'object_storage.streaming_playlists.prefix', 'object_storage.streaming_playlists.base_url', 'object_storage.web_videos.bucket_name', 'object_storage.upload_acl.public',
'object_storage.web_videos.prefix', 'object_storage.web_videos.base_url', 'object_storage.original_video_files.bucket_name', 'object_storage.upload_acl.private',
'object_storage.original_video_files.prefix', 'object_storage.original_video_files.base_url', 'object_storage.max_request_attempts', 'object_storage.proxy.proxify_private_files',
'object_storage.captions.bucket_name', 'object_storage.captions.prefix', 'object_storage.captions.base_url', 'object_storage.credentials.access_key_id',
'object_storage.credentials.secret_access_key',
'object_storage.max_upload_part',
'object_storage.streaming_playlists.bucket_name',
'object_storage.streaming_playlists.prefix',
'object_storage.streaming_playlists.base_url',
'object_storage.web_videos.bucket_name',
'object_storage.web_videos.prefix',
'object_storage.web_videos.base_url',
'object_storage.original_video_files.bucket_name',
'object_storage.original_video_files.prefix',
'object_storage.original_video_files.base_url',
'object_storage.max_request_attempts',
'object_storage.captions.bucket_name',
'object_storage.captions.prefix',
'object_storage.captions.base_url',
'theme.default', 'theme.default',
'feeds.videos.count', 'feeds.comments.count', 'feeds.videos.count',
'geo_ip.enabled', 'geo_ip.country.database_url', 'geo_ip.city.database_url', 'feeds.comments.count',
'geo_ip.enabled',
'geo_ip.country.database_url',
'geo_ip.city.database_url',
'remote_redundancy.videos.accept_from', 'remote_redundancy.videos.accept_from',
'federation.enabled', 'federation.prevent_ssrf', 'federation.videos.federate_unlisted', 'federation.videos.cleanup_remote_interactions', 'federation.enabled',
'peertube.check_latest_version.enabled', 'peertube.check_latest_version.url', 'federation.prevent_ssrf',
'search.remote_uri.users', 'search.remote_uri.anonymous', 'search.search_index.enabled', 'search.search_index.url', 'federation.videos.federate_unlisted',
'search.search_index.disable_local_search', 'search.search_index.is_default_search', 'federation.videos.cleanup_remote_interactions',
'live.enabled', 'live.allow_replay', 'live.latency_setting.enabled', 'live.max_duration', 'peertube.check_latest_version.enabled',
'live.max_user_lives', 'live.max_instance_lives', 'peertube.check_latest_version.url',
'live.rtmp.enabled', 'live.rtmp.port', 'live.rtmp.hostname', 'live.rtmp.public_hostname', 'search.remote_uri.users',
'live.rtmps.enabled', 'live.rtmps.port', 'live.rtmps.hostname', 'live.rtmps.public_hostname', 'search.remote_uri.anonymous',
'live.rtmps.key_file', 'live.rtmps.cert_file', 'search.search_index.enabled',
'live.transcoding.enabled', 'live.transcoding.threads', 'live.transcoding.profile', 'search.search_index.url',
'live.transcoding.resolutions.144p', 'live.transcoding.resolutions.240p', 'live.transcoding.resolutions.360p', 'search.search_index.disable_local_search',
'live.transcoding.resolutions.480p', 'live.transcoding.resolutions.720p', 'live.transcoding.resolutions.1080p', 'search.search_index.is_default_search',
'live.transcoding.resolutions.1440p', 'live.transcoding.resolutions.2160p', 'live.transcoding.always_transcode_original_resolution', 'live.enabled',
'live.transcoding.fps.max', 'live.transcoding.remote_runners.enabled', 'live.allow_replay',
'storyboards.enabled' 'live.latency_setting.enabled',
'live.max_duration',
'live.max_user_lives',
'live.max_instance_lives',
'live.rtmp.enabled',
'live.rtmp.port',
'live.rtmp.hostname',
'live.rtmp.public_hostname',
'live.rtmps.enabled',
'live.rtmps.port',
'live.rtmps.hostname',
'live.rtmps.public_hostname',
'live.rtmps.key_file',
'live.rtmps.cert_file',
'live.transcoding.enabled',
'live.transcoding.threads',
'live.transcoding.profile',
'live.transcoding.resolutions.144p',
'live.transcoding.resolutions.240p',
'live.transcoding.resolutions.360p',
'live.transcoding.resolutions.480p',
'live.transcoding.resolutions.720p',
'live.transcoding.resolutions.1080p',
'live.transcoding.resolutions.1440p',
'live.transcoding.resolutions.2160p',
'live.transcoding.always_transcode_original_resolution',
'live.transcoding.fps.max',
'live.transcoding.remote_runners.enabled',
'storyboards.enabled',
'webrtc.stun_servers',
'nsfw_flags_settings.enabled'
] ]
const requiredAlternatives = [ const requiredAlternatives = [
@ -130,7 +288,7 @@ function checkMissedConfig () {
// Check the available codecs // Check the available codecs
// We get CONFIG by param to not import it in this file (import orders) // We get CONFIG by param to not import it in this file (import orders)
async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) { export async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
if (CONFIG.TRANSCODING.ENABLED === false) return undefined if (CONFIG.TRANSCODING.ENABLED === false) return undefined
const Ffmpeg = (await import('fluent-ffmpeg')).default const Ffmpeg = (await import('fluent-ffmpeg')).default
@ -149,7 +307,7 @@ async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
} }
} }
function checkNodeVersion () { export function checkNodeVersion () {
const v = process.version const v = process.version
const { major } = parseSemVersion(v) const { major } = parseSemVersion(v)
@ -159,11 +317,3 @@ function checkNodeVersion () {
throw new Error('Your NodeJS version ' + v + ' is not supported. Please upgrade.') throw new Error('Your NodeJS version ' + v + ' is not supported. Please upgrade.')
} }
} }
// ---------------------------------------------------------------------------
export {
checkFFmpeg,
checkMissedConfig,
checkNodeVersion
}

View file

@ -74,34 +74,60 @@ const CONFIG = {
} }
}, },
NSFW_FLAGS_SETTINGS: {
ENABLED: config.get<boolean>('nsfw_flags_settings.enabled')
},
CLIENT: { CLIENT: {
VIDEOS: { VIDEOS: {
MINIATURE: { MINIATURE: {
get PREFER_AUTHOR_DISPLAY_NAME () { return config.get<boolean>('client.videos.miniature.prefer_author_display_name') } get PREFER_AUTHOR_DISPLAY_NAME () {
return config.get<boolean>('client.videos.miniature.prefer_author_display_name')
}
}, },
RESUMABLE_UPLOAD: { RESUMABLE_UPLOAD: {
get MAX_CHUNK_SIZE () { return parseBytes(config.get<number>('client.videos.resumable_upload.max_chunk_size') || 0) } get MAX_CHUNK_SIZE () {
return parseBytes(config.get<number>('client.videos.resumable_upload.max_chunk_size') || 0)
}
} }
}, },
MENU: { MENU: {
LOGIN: { LOGIN: {
get REDIRECT_ON_SINGLE_EXTERNAL_AUTH () { return config.get<boolean>('client.menu.login.redirect_on_single_external_auth') } get REDIRECT_ON_SINGLE_EXTERNAL_AUTH () {
return config.get<boolean>('client.menu.login.redirect_on_single_external_auth')
}
} }
}, },
OPEN_IN_APP: { OPEN_IN_APP: {
ANDROID: { ANDROID: {
INTENT: { INTENT: {
get ENABLED () { return config.get<boolean>('client.open_in_app.android.intent.enabled') }, get ENABLED () {
get HOST () { return config.get<string>('client.open_in_app.android.intent.host') }, return config.get<boolean>('client.open_in_app.android.intent.enabled')
get SCHEME () { return config.get<string>('client.open_in_app.android.intent.scheme') }, },
get FALLBACK_URL () { return config.get<string>('client.open_in_app.android.intent.fallback_url') } get HOST () {
return config.get<string>('client.open_in_app.android.intent.host')
},
get SCHEME () {
return config.get<string>('client.open_in_app.android.intent.scheme')
},
get FALLBACK_URL () {
return config.get<string>('client.open_in_app.android.intent.fallback_url')
}
} }
}, },
IOS: { IOS: {
get ENABLED () { return config.get<boolean>('client.open_in_app.ios.enabled') }, get ENABLED () {
get HOST () { return config.get<string>('client.open_in_app.ios.host') }, return config.get<boolean>('client.open_in_app.ios.enabled')
get SCHEME () { return config.get<string>('client.open_in_app.ios.scheme') }, },
get FALLBACK_URL () { return config.get<string>('client.open_in_app.ios.fallback_url') } get HOST () {
return config.get<string>('client.open_in_app.ios.host')
},
get SCHEME () {
return config.get<string>('client.open_in_app.ios.scheme')
},
get FALLBACK_URL () {
return config.get<string>('client.open_in_app.ios.fallback_url')
}
} }
} }
}, },
@ -122,7 +148,9 @@ const CONFIG = {
} }
}, },
PLAYER: { PLAYER: {
get AUTO_PLAY () { return config.get<boolean>('defaults.player.auto_play') } get AUTO_PLAY () {
return config.get<boolean>('defaults.player.auto_play')
}
} }
}, },
@ -293,8 +321,12 @@ const CONFIG = {
VIDEOS: { VIDEOS: {
INTERVAL_DAYS: config.get<number>('trending.videos.interval_days'), INTERVAL_DAYS: config.get<number>('trending.videos.interval_days'),
ALGORITHMS: { ALGORITHMS: {
get ENABLED () { return config.get<string[]>('trending.videos.algorithms.enabled') }, get ENABLED () {
get DEFAULT () { return config.get<string>('trending.videos.algorithms.default') } return config.get<string[]>('trending.videos.algorithms.enabled')
},
get DEFAULT () {
return config.get<string>('trending.videos.algorithms.default')
}
} }
} }
}, },
@ -423,177 +455,353 @@ const CONFIG = {
STUN_SERVERS: config.get<string[]>('webrtc.stun_servers') STUN_SERVERS: config.get<string[]>('webrtc.stun_servers')
}, },
ADMIN: { ADMIN: {
get EMAIL () { return config.get<string>('admin.email') } get EMAIL () {
return config.get<string>('admin.email')
}
}, },
CONTACT_FORM: { CONTACT_FORM: {
get ENABLED () { return config.get<boolean>('contact_form.enabled') } get ENABLED () {
return config.get<boolean>('contact_form.enabled')
}
}, },
SIGNUP: { SIGNUP: {
get ENABLED () { return config.get<boolean>('signup.enabled') }, get ENABLED () {
get REQUIRES_APPROVAL () { return config.get<boolean>('signup.requires_approval') }, return config.get<boolean>('signup.enabled')
get LIMIT () { return config.get<number>('signup.limit') }, },
get REQUIRES_EMAIL_VERIFICATION () { return config.get<boolean>('signup.requires_email_verification') }, get REQUIRES_APPROVAL () {
get MINIMUM_AGE () { return config.get<number>('signup.minimum_age') }, return config.get<boolean>('signup.requires_approval')
},
get LIMIT () {
return config.get<number>('signup.limit')
},
get REQUIRES_EMAIL_VERIFICATION () {
return config.get<boolean>('signup.requires_email_verification')
},
get MINIMUM_AGE () {
return config.get<number>('signup.minimum_age')
},
FILTERS: { FILTERS: {
CIDR: { CIDR: {
get WHITELIST () { return config.get<string[]>('signup.filters.cidr.whitelist') }, get WHITELIST () {
get BLACKLIST () { return config.get<string[]>('signup.filters.cidr.blacklist') } return config.get<string[]>('signup.filters.cidr.whitelist')
},
get BLACKLIST () {
return config.get<string[]>('signup.filters.cidr.blacklist')
}
} }
} }
}, },
USER: { USER: {
HISTORY: { HISTORY: {
VIDEOS: { VIDEOS: {
get ENABLED () { return config.get<boolean>('user.history.videos.enabled') } get ENABLED () {
return config.get<boolean>('user.history.videos.enabled')
}
} }
}, },
get VIDEO_QUOTA () { return parseBytes(config.get<number>('user.video_quota')) }, get VIDEO_QUOTA () {
get VIDEO_QUOTA_DAILY () { return parseBytes(config.get<number>('user.video_quota_daily')) }, return parseBytes(config.get<number>('user.video_quota'))
get DEFAULT_CHANNEL_NAME () { return config.get<string>('user.default_channel_name') } },
get VIDEO_QUOTA_DAILY () {
return parseBytes(config.get<number>('user.video_quota_daily'))
},
get DEFAULT_CHANNEL_NAME () {
return config.get<string>('user.default_channel_name')
}
}, },
VIDEO_CHANNELS: { VIDEO_CHANNELS: {
get MAX_PER_USER () { return config.get<number>('video_channels.max_per_user') } get MAX_PER_USER () {
return config.get<number>('video_channels.max_per_user')
}
}, },
TRANSCODING: { TRANSCODING: {
get ENABLED () { return config.get<boolean>('transcoding.enabled') }, get ENABLED () {
ORIGINAL_FILE: { return config.get<boolean>('transcoding.enabled')
get KEEP () { return config.get<boolean>('transcoding.original_file.keep') } },
ORIGINAL_FILE: {
get KEEP () {
return config.get<boolean>('transcoding.original_file.keep')
}
},
get ALLOW_ADDITIONAL_EXTENSIONS () {
return config.get<boolean>('transcoding.allow_additional_extensions')
},
get ALLOW_AUDIO_FILES () {
return config.get<boolean>('transcoding.allow_audio_files')
},
get THREADS () {
return config.get<number>('transcoding.threads')
},
get CONCURRENCY () {
return config.get<number>('transcoding.concurrency')
},
get PROFILE () {
return config.get<string>('transcoding.profile')
},
get ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION () {
return config.get<boolean>('transcoding.always_transcode_original_resolution')
}, },
get ALLOW_ADDITIONAL_EXTENSIONS () { return config.get<boolean>('transcoding.allow_additional_extensions') },
get ALLOW_AUDIO_FILES () { return config.get<boolean>('transcoding.allow_audio_files') },
get THREADS () { return config.get<number>('transcoding.threads') },
get CONCURRENCY () { return config.get<number>('transcoding.concurrency') },
get PROFILE () { return config.get<string>('transcoding.profile') },
get ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION () { return config.get<boolean>('transcoding.always_transcode_original_resolution') },
RESOLUTIONS: { RESOLUTIONS: {
get '0p' () { return config.get<boolean>('transcoding.resolutions.0p') }, get '0p' () {
get '144p' () { return config.get<boolean>('transcoding.resolutions.144p') }, return config.get<boolean>('transcoding.resolutions.0p')
get '240p' () { return config.get<boolean>('transcoding.resolutions.240p') }, },
get '360p' () { return config.get<boolean>('transcoding.resolutions.360p') }, get '144p' () {
get '480p' () { return config.get<boolean>('transcoding.resolutions.480p') }, return config.get<boolean>('transcoding.resolutions.144p')
get '720p' () { return config.get<boolean>('transcoding.resolutions.720p') }, },
get '1080p' () { return config.get<boolean>('transcoding.resolutions.1080p') }, get '240p' () {
get '1440p' () { return config.get<boolean>('transcoding.resolutions.1440p') }, return config.get<boolean>('transcoding.resolutions.240p')
get '2160p' () { return config.get<boolean>('transcoding.resolutions.2160p') } },
get '360p' () {
return config.get<boolean>('transcoding.resolutions.360p')
},
get '480p' () {
return config.get<boolean>('transcoding.resolutions.480p')
},
get '720p' () {
return config.get<boolean>('transcoding.resolutions.720p')
},
get '1080p' () {
return config.get<boolean>('transcoding.resolutions.1080p')
},
get '1440p' () {
return config.get<boolean>('transcoding.resolutions.1440p')
},
get '2160p' () {
return config.get<boolean>('transcoding.resolutions.2160p')
}
}, },
FPS: { FPS: {
get MAX () { return config.get<number>('transcoding.fps.max') } get MAX () {
return config.get<number>('transcoding.fps.max')
}
}, },
HLS: { HLS: {
get ENABLED () { return config.get<boolean>('transcoding.hls.enabled') }, get ENABLED () {
get SPLIT_AUDIO_AND_VIDEO () { return config.get<boolean>('transcoding.hls.split_audio_and_video') } return config.get<boolean>('transcoding.hls.enabled')
},
get SPLIT_AUDIO_AND_VIDEO () {
return config.get<boolean>('transcoding.hls.split_audio_and_video')
}
}, },
WEB_VIDEOS: { WEB_VIDEOS: {
get ENABLED () { return config.get<boolean>('transcoding.web_videos.enabled') } get ENABLED () {
return config.get<boolean>('transcoding.web_videos.enabled')
}
}, },
REMOTE_RUNNERS: { REMOTE_RUNNERS: {
get ENABLED () { return config.get<boolean>('transcoding.remote_runners.enabled') } get ENABLED () {
return config.get<boolean>('transcoding.remote_runners.enabled')
}
} }
}, },
LIVE: { LIVE: {
get ENABLED () { return config.get<boolean>('live.enabled') }, get ENABLED () {
return config.get<boolean>('live.enabled')
},
get MAX_DURATION () { return parseDurationToMs(config.get<string>('live.max_duration')) }, get MAX_DURATION () {
get MAX_INSTANCE_LIVES () { return config.get<number>('live.max_instance_lives') }, return parseDurationToMs(config.get<string>('live.max_duration'))
get MAX_USER_LIVES () { return config.get<number>('live.max_user_lives') }, },
get MAX_INSTANCE_LIVES () {
return config.get<number>('live.max_instance_lives')
},
get MAX_USER_LIVES () {
return config.get<number>('live.max_user_lives')
},
get ALLOW_REPLAY () { return config.get<boolean>('live.allow_replay') }, get ALLOW_REPLAY () {
return config.get<boolean>('live.allow_replay')
},
LATENCY_SETTING: { LATENCY_SETTING: {
get ENABLED () { return config.get<boolean>('live.latency_setting.enabled') } get ENABLED () {
return config.get<boolean>('live.latency_setting.enabled')
}
}, },
RTMP: { RTMP: {
get ENABLED () { return config.get<boolean>('live.rtmp.enabled') }, get ENABLED () {
get PORT () { return config.get<number>('live.rtmp.port') }, return config.get<boolean>('live.rtmp.enabled')
get HOSTNAME () { return config.get<number>('live.rtmp.hostname') }, },
get PUBLIC_HOSTNAME () { return config.get<number>('live.rtmp.public_hostname') } get PORT () {
return config.get<number>('live.rtmp.port')
},
get HOSTNAME () {
return config.get<number>('live.rtmp.hostname')
},
get PUBLIC_HOSTNAME () {
return config.get<number>('live.rtmp.public_hostname')
}
}, },
RTMPS: { RTMPS: {
get ENABLED () { return config.get<boolean>('live.rtmps.enabled') }, get ENABLED () {
get PORT () { return config.get<number>('live.rtmps.port') }, return config.get<boolean>('live.rtmps.enabled')
get HOSTNAME () { return config.get<number>('live.rtmps.hostname') }, },
get PUBLIC_HOSTNAME () { return config.get<number>('live.rtmps.public_hostname') }, get PORT () {
get KEY_FILE () { return config.get<string>('live.rtmps.key_file') }, return config.get<number>('live.rtmps.port')
get CERT_FILE () { return config.get<string>('live.rtmps.cert_file') } },
get HOSTNAME () {
return config.get<number>('live.rtmps.hostname')
},
get PUBLIC_HOSTNAME () {
return config.get<number>('live.rtmps.public_hostname')
},
get KEY_FILE () {
return config.get<string>('live.rtmps.key_file')
},
get CERT_FILE () {
return config.get<string>('live.rtmps.cert_file')
}
}, },
TRANSCODING: { TRANSCODING: {
get ENABLED () { return config.get<boolean>('live.transcoding.enabled') }, get ENABLED () {
get THREADS () { return config.get<number>('live.transcoding.threads') }, return config.get<boolean>('live.transcoding.enabled')
get PROFILE () { return config.get<string>('live.transcoding.profile') }, },
get THREADS () {
return config.get<number>('live.transcoding.threads')
},
get PROFILE () {
return config.get<string>('live.transcoding.profile')
},
get ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION () { return config.get<boolean>('live.transcoding.always_transcode_original_resolution') }, get ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION () {
return config.get<boolean>('live.transcoding.always_transcode_original_resolution')
},
RESOLUTIONS: { RESOLUTIONS: {
get '0p' () { return config.get<boolean>('live.transcoding.resolutions.0p') }, get '0p' () {
get '144p' () { return config.get<boolean>('live.transcoding.resolutions.144p') }, return config.get<boolean>('live.transcoding.resolutions.0p')
get '240p' () { return config.get<boolean>('live.transcoding.resolutions.240p') }, },
get '360p' () { return config.get<boolean>('live.transcoding.resolutions.360p') }, get '144p' () {
get '480p' () { return config.get<boolean>('live.transcoding.resolutions.480p') }, return config.get<boolean>('live.transcoding.resolutions.144p')
get '720p' () { return config.get<boolean>('live.transcoding.resolutions.720p') }, },
get '1080p' () { return config.get<boolean>('live.transcoding.resolutions.1080p') }, get '240p' () {
get '1440p' () { return config.get<boolean>('live.transcoding.resolutions.1440p') }, return config.get<boolean>('live.transcoding.resolutions.240p')
get '2160p' () { return config.get<boolean>('live.transcoding.resolutions.2160p') } },
get '360p' () {
return config.get<boolean>('live.transcoding.resolutions.360p')
},
get '480p' () {
return config.get<boolean>('live.transcoding.resolutions.480p')
},
get '720p' () {
return config.get<boolean>('live.transcoding.resolutions.720p')
},
get '1080p' () {
return config.get<boolean>('live.transcoding.resolutions.1080p')
},
get '1440p' () {
return config.get<boolean>('live.transcoding.resolutions.1440p')
},
get '2160p' () {
return config.get<boolean>('live.transcoding.resolutions.2160p')
}
}, },
FPS: { FPS: {
get MAX () { return config.get<number>('live.transcoding.fps.max') } get MAX () {
return config.get<number>('live.transcoding.fps.max')
}
}, },
REMOTE_RUNNERS: { REMOTE_RUNNERS: {
get ENABLED () { return config.get<boolean>('live.transcoding.remote_runners.enabled') } get ENABLED () {
return config.get<boolean>('live.transcoding.remote_runners.enabled')
}
} }
} }
}, },
VIDEO_STUDIO: { VIDEO_STUDIO: {
get ENABLED () { return config.get<boolean>('video_studio.enabled') }, get ENABLED () {
return config.get<boolean>('video_studio.enabled')
},
REMOTE_RUNNERS: { REMOTE_RUNNERS: {
get ENABLED () { return config.get<boolean>('video_studio.remote_runners.enabled') } get ENABLED () {
return config.get<boolean>('video_studio.remote_runners.enabled')
}
} }
}, },
VIDEO_FILE: { VIDEO_FILE: {
UPDATE: { UPDATE: {
get ENABLED () { return config.get<boolean>('video_file.update.enabled') } get ENABLED () {
return config.get<boolean>('video_file.update.enabled')
}
} }
}, },
VIDEO_TRANSCRIPTION: { VIDEO_TRANSCRIPTION: {
get ENABLED () { return config.get<boolean>('video_transcription.enabled') }, get ENABLED () {
get ENGINE () { return config.get<TranscriptionEngineName>('video_transcription.engine') }, return config.get<boolean>('video_transcription.enabled')
get ENGINE_PATH () { return config.get<string>('video_transcription.engine_path') }, },
get MODEL () { return config.get<WhisperBuiltinModelName>('video_transcription.model') }, get ENGINE () {
get MODEL_PATH () { return config.get<string>('video_transcription.model_path') }, return config.get<TranscriptionEngineName>('video_transcription.engine')
},
get ENGINE_PATH () {
return config.get<string>('video_transcription.engine_path')
},
get MODEL () {
return config.get<WhisperBuiltinModelName>('video_transcription.model')
},
get MODEL_PATH () {
return config.get<string>('video_transcription.model_path')
},
REMOTE_RUNNERS: { REMOTE_RUNNERS: {
get ENABLED () { return config.get<boolean>('video_transcription.remote_runners.enabled') } get ENABLED () {
return config.get<boolean>('video_transcription.remote_runners.enabled')
}
} }
}, },
IMPORT: { IMPORT: {
VIDEOS: { VIDEOS: {
get CONCURRENCY () { return config.get<number>('import.videos.concurrency') }, get CONCURRENCY () {
get TIMEOUT () { return parseDurationToMs(config.get<string>('import.videos.timeout')) }, return config.get<number>('import.videos.concurrency')
},
get TIMEOUT () {
return parseDurationToMs(config.get<string>('import.videos.timeout'))
},
HTTP: { HTTP: {
get ENABLED () { return config.get<boolean>('import.videos.http.enabled') }, get ENABLED () {
return config.get<boolean>('import.videos.http.enabled')
YOUTUBE_DL_RELEASE: {
get URL () { return config.get<string>('import.videos.http.youtube_dl_release.url') },
get NAME () { return config.get<string>('import.videos.http.youtube_dl_release.name') },
get PYTHON_PATH () { return config.get<string>('import.videos.http.youtube_dl_release.python_path') }
}, },
get FORCE_IPV4 () { return config.get<boolean>('import.videos.http.force_ipv4') }, YOUTUBE_DL_RELEASE: {
get URL () {
return config.get<string>('import.videos.http.youtube_dl_release.url')
},
get NAME () {
return config.get<string>('import.videos.http.youtube_dl_release.name')
},
get PYTHON_PATH () {
return config.get<string>('import.videos.http.youtube_dl_release.python_path')
}
},
get PROXIES () { return config.get<string[]>('import.videos.http.proxies') } get FORCE_IPV4 () {
return config.get<boolean>('import.videos.http.force_ipv4')
},
get PROXIES () {
return config.get<string[]>('import.videos.http.proxies')
}
}, },
TORRENT: { TORRENT: {
get ENABLED () { return config.get<boolean>('import.videos.torrent.enabled') } get ENABLED () {
return config.get<boolean>('import.videos.torrent.enabled')
}
} }
}, },
VIDEO_CHANNEL_SYNCHRONIZATION: { VIDEO_CHANNEL_SYNCHRONIZATION: {
get ENABLED () { return config.get<boolean>('import.video_channel_synchronization.enabled') }, get ENABLED () {
get MAX_PER_USER () { return config.get<number>('import.video_channel_synchronization.max_per_user') }, return config.get<boolean>('import.video_channel_synchronization.enabled')
get CHECK_INTERVAL () { return parseDurationToMs(config.get<string>('import.video_channel_synchronization.check_interval')) }, },
get MAX_PER_USER () {
return config.get<number>('import.video_channel_synchronization.max_per_user')
},
get CHECK_INTERVAL () {
return parseDurationToMs(config.get<string>('import.video_channel_synchronization.check_interval'))
},
get VIDEOS_LIMIT_PER_SYNCHRONIZATION () { get VIDEOS_LIMIT_PER_SYNCHRONIZATION () {
return config.get<number>('import.video_channel_synchronization.videos_limit_per_synchronization') return config.get<number>('import.video_channel_synchronization.videos_limit_per_synchronization')
}, },
@ -602,88 +810,162 @@ const CONFIG = {
} }
}, },
USERS: { USERS: {
get ENABLED () { return config.get<boolean>('import.users.enabled') } get ENABLED () {
return config.get<boolean>('import.users.enabled')
}
} }
}, },
EXPORT: { EXPORT: {
USERS: { USERS: {
get ENABLED () { return config.get<boolean>('export.users.enabled') }, get ENABLED () {
get MAX_USER_VIDEO_QUOTA () { return parseBytes(config.get<string>('export.users.max_user_video_quota')) }, return config.get<boolean>('export.users.enabled')
get EXPORT_EXPIRATION () { return parseDurationToMs(config.get<string>('export.users.export_expiration')) } },
get MAX_USER_VIDEO_QUOTA () {
return parseBytes(config.get<string>('export.users.max_user_video_quota'))
},
get EXPORT_EXPIRATION () {
return parseDurationToMs(config.get<string>('export.users.export_expiration'))
}
} }
}, },
AUTO_BLACKLIST: { AUTO_BLACKLIST: {
VIDEOS: { VIDEOS: {
OF_USERS: { OF_USERS: {
get ENABLED () { return config.get<boolean>('auto_blacklist.videos.of_users.enabled') } get ENABLED () {
return config.get<boolean>('auto_blacklist.videos.of_users.enabled')
}
} }
} }
}, },
CACHE: { CACHE: {
PREVIEWS: { PREVIEWS: {
get SIZE () { return config.get<number>('cache.previews.size') } get SIZE () {
return config.get<number>('cache.previews.size')
}
}, },
VIDEO_CAPTIONS: { VIDEO_CAPTIONS: {
get SIZE () { return config.get<number>('cache.captions.size') } get SIZE () {
return config.get<number>('cache.captions.size')
}
}, },
TORRENTS: { TORRENTS: {
get SIZE () { return config.get<number>('cache.torrents.size') } get SIZE () {
return config.get<number>('cache.torrents.size')
}
}, },
STORYBOARDS: { STORYBOARDS: {
get SIZE () { return config.get<number>('cache.storyboards.size') } get SIZE () {
return config.get<number>('cache.storyboards.size')
}
} }
}, },
INSTANCE: { INSTANCE: {
get NAME () { return config.get<string>('instance.name') }, get NAME () {
get SHORT_DESCRIPTION () { return config.get<string>('instance.short_description') }, return config.get<string>('instance.name')
get DESCRIPTION () { return config.get<string>('instance.description') }, },
get TERMS () { return config.get<string>('instance.terms') }, get SHORT_DESCRIPTION () {
get CODE_OF_CONDUCT () { return config.get<string>('instance.code_of_conduct') }, return config.get<string>('instance.short_description')
},
get DESCRIPTION () {
return config.get<string>('instance.description')
},
get TERMS () {
return config.get<string>('instance.terms')
},
get CODE_OF_CONDUCT () {
return config.get<string>('instance.code_of_conduct')
},
get CREATION_REASON () { return config.get<string>('instance.creation_reason') }, get CREATION_REASON () {
return config.get<string>('instance.creation_reason')
},
get MODERATION_INFORMATION () { return config.get<string>('instance.moderation_information') }, get MODERATION_INFORMATION () {
get ADMINISTRATOR () { return config.get<string>('instance.administrator') }, return config.get<string>('instance.moderation_information')
get MAINTENANCE_LIFETIME () { return config.get<string>('instance.maintenance_lifetime') }, },
get BUSINESS_MODEL () { return config.get<string>('instance.business_model') }, get ADMINISTRATOR () {
get HARDWARE_INFORMATION () { return config.get<string>('instance.hardware_information') }, return config.get<string>('instance.administrator')
},
get MAINTENANCE_LIFETIME () {
return config.get<string>('instance.maintenance_lifetime')
},
get BUSINESS_MODEL () {
return config.get<string>('instance.business_model')
},
get HARDWARE_INFORMATION () {
return config.get<string>('instance.hardware_information')
},
get LANGUAGES () { return config.get<string[]>('instance.languages') || [] }, get LANGUAGES () {
get CATEGORIES () { return config.get<number[]>('instance.categories') || [] }, return config.get<string[]>('instance.languages') || []
},
get CATEGORIES () {
return config.get<number[]>('instance.categories') || []
},
get IS_NSFW () { return config.get<boolean>('instance.is_nsfw') }, get IS_NSFW () {
get DEFAULT_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') }, return config.get<boolean>('instance.is_nsfw')
},
get DEFAULT_NSFW_POLICY () {
return config.get<NSFWPolicyType>('instance.default_nsfw_policy')
},
get SERVER_COUNTRY () { return config.get<string>('instance.server_country') }, get SERVER_COUNTRY () {
return config.get<string>('instance.server_country')
},
SUPPORT: { SUPPORT: {
get TEXT () { return config.get<string>('instance.support.text') } get TEXT () {
return config.get<string>('instance.support.text')
}
}, },
SOCIAL: { SOCIAL: {
get EXTERNAL_LINK () { return config.get<string>('instance.social.external_link') }, get EXTERNAL_LINK () {
get MASTODON_LINK () { return config.get<string>('instance.social.mastodon_link') }, return config.get<string>('instance.social.external_link')
get BLUESKY () { return config.get<string>('instance.social.bluesky_link') } },
get MASTODON_LINK () {
return config.get<string>('instance.social.mastodon_link')
},
get BLUESKY () {
return config.get<string>('instance.social.bluesky_link')
}
}, },
get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') }, get DEFAULT_CLIENT_ROUTE () {
return config.get<string>('instance.default_client_route')
},
CUSTOMIZATIONS: { CUSTOMIZATIONS: {
get JAVASCRIPT () { return config.get<string>('instance.customizations.javascript') }, get JAVASCRIPT () {
get CSS () { return config.get<string>('instance.customizations.css') } return config.get<string>('instance.customizations.javascript')
},
get CSS () {
return config.get<string>('instance.customizations.css')
}
}, },
get ROBOTS () { return config.get<string>('instance.robots') }, get ROBOTS () {
get SECURITYTXT () { return config.get<string>('instance.securitytxt') } return config.get<string>('instance.robots')
},
get SECURITYTXT () {
return config.get<string>('instance.securitytxt')
}
}, },
SERVICES: { SERVICES: {
TWITTER: { TWITTER: {
get USERNAME () { return config.get<string>('services.twitter.username') } get USERNAME () {
return config.get<string>('services.twitter.username')
}
} }
}, },
FOLLOWERS: { FOLLOWERS: {
INSTANCE: { INSTANCE: {
get ENABLED () { return config.get<boolean>('followers.instance.enabled') }, get ENABLED () {
get MANUAL_APPROVAL () { return config.get<boolean>('followers.instance.manual_approval') } return config.get<boolean>('followers.instance.enabled')
},
get MANUAL_APPROVAL () {
return config.get<boolean>('followers.instance.manual_approval')
}
} }
}, },
FOLLOWINGS: { FOLLOWINGS: {
@ -704,28 +986,52 @@ const CONFIG = {
} }
}, },
THEME: { THEME: {
get DEFAULT () { return config.get<string>('theme.default') } get DEFAULT () {
return config.get<string>('theme.default')
}
}, },
BROADCAST_MESSAGE: { BROADCAST_MESSAGE: {
get ENABLED () { return config.get<boolean>('broadcast_message.enabled') }, get ENABLED () {
get MESSAGE () { return config.get<string>('broadcast_message.message') }, return config.get<boolean>('broadcast_message.enabled')
get LEVEL () { return config.get<BroadcastMessageLevel>('broadcast_message.level') }, },
get DISMISSABLE () { return config.get<boolean>('broadcast_message.dismissable') } get MESSAGE () {
return config.get<string>('broadcast_message.message')
},
get LEVEL () {
return config.get<BroadcastMessageLevel>('broadcast_message.level')
},
get DISMISSABLE () {
return config.get<boolean>('broadcast_message.dismissable')
}
}, },
SEARCH: { SEARCH: {
REMOTE_URI: { REMOTE_URI: {
get USERS () { return config.get<boolean>('search.remote_uri.users') }, get USERS () {
get ANONYMOUS () { return config.get<boolean>('search.remote_uri.anonymous') } return config.get<boolean>('search.remote_uri.users')
},
get ANONYMOUS () {
return config.get<boolean>('search.remote_uri.anonymous')
}
}, },
SEARCH_INDEX: { SEARCH_INDEX: {
get ENABLED () { return config.get<boolean>('search.search_index.enabled') }, get ENABLED () {
get URL () { return config.get<string>('search.search_index.url') }, return config.get<boolean>('search.search_index.enabled')
get DISABLE_LOCAL_SEARCH () { return config.get<boolean>('search.search_index.disable_local_search') }, },
get IS_DEFAULT_SEARCH () { return config.get<boolean>('search.search_index.is_default_search') } get URL () {
return config.get<string>('search.search_index.url')
},
get DISABLE_LOCAL_SEARCH () {
return config.get<boolean>('search.search_index.disable_local_search')
},
get IS_DEFAULT_SEARCH () {
return config.get<boolean>('search.search_index.is_default_search')
}
} }
}, },
STORYBOARDS: { STORYBOARDS: {
get ENABLED () { return config.get<boolean>('storyboards.enabled') } get ENABLED () {
return config.get<boolean>('storyboards.enabled')
}
} }
} }
@ -791,7 +1097,6 @@ function buildVideosRedundancy (objs: any[]): VideosRedundancyStrategy[] {
} }
export function reloadConfig () { export function reloadConfig () {
function getConfigDirectories () { function getConfigDirectories () {
if (process.env.NODE_CONFIG_DIR) { if (process.env.NODE_CONFIG_DIR) {
return process.env.NODE_CONFIG_DIR.split(':') return process.env.NODE_CONFIG_DIR.split(':')
@ -804,7 +1109,7 @@ export function reloadConfig () {
const directories = getConfigDirectories() const directories = getConfigDirectories()
for (const fileName in require.cache) { for (const fileName in require.cache) {
if (directories.some((dir) => fileName.includes(dir)) === false) { if (directories.some(dir => fileName.includes(dir)) === false) {
continue continue
} }

View file

@ -19,14 +19,11 @@ import { getThemeOrDefault } from './plugins/theme-utils.js'
import { VideoTranscodingProfilesManager } from './transcoding/default-transcoding-profiles.js' import { VideoTranscodingProfilesManager } from './transcoding/default-transcoding-profiles.js'
/** /**
*
* Used to send the server config to clients (using REST/API or plugins API) * Used to send the server config to clients (using REST/API or plugins API)
* We need a singleton class to manage config state depending on external events (to build menu entries etc) * We need a singleton class to manage config state depending on external events (to build menu entries etc)
*
*/ */
class ServerConfigManager { class ServerConfigManager {
private static instance: ServerConfigManager private static instance: ServerConfigManager
private serverCommit: string private serverCommit: string
@ -356,6 +353,10 @@ class ServerConfigManager {
webrtc: { webrtc: {
stunServers: CONFIG.WEBRTC.STUN_SERVERS stunServers: CONFIG.WEBRTC.STUN_SERVERS
},
nsfwFlagsSettings: {
enabled: CONFIG.NSFW_FLAGS_SETTINGS.ENABLED
} }
} }
} }
@ -363,14 +364,12 @@ class ServerConfigManager {
async getServerConfig (ip?: string): Promise<ServerConfig> { async getServerConfig (ip?: string): Promise<ServerConfig> {
const { allowed } = await Hooks.wrapPromiseFun( const { allowed } = await Hooks.wrapPromiseFun(
isSignupAllowed, isSignupAllowed,
{ {
ip, ip,
signupMode: CONFIG.SIGNUP.REQUIRES_APPROVAL signupMode: CONFIG.SIGNUP.REQUIRES_APPROVAL
? 'request-registration' ? 'request-registration'
: 'direct-registration' : 'direct-registration'
}, },
CONFIG.SIGNUP.REQUIRES_APPROVAL CONFIG.SIGNUP.REQUIRES_APPROVAL
? 'filter:api.user.request-signup.allowed.result' ? 'filter:api.user.request-signup.allowed.result'
: 'filter:api.user.signup.allowed.result' : 'filter:api.user.signup.allowed.result'
@ -393,14 +392,14 @@ class ServerConfigManager {
getRegisteredThemes () { getRegisteredThemes () {
return PluginManager.Instance.getRegisteredThemes() return PluginManager.Instance.getRegisteredThemes()
.map(t => ({ .map(t => ({
npmName: PluginModel.buildNpmName(t.name, t.type), npmName: PluginModel.buildNpmName(t.name, t.type),
name: t.name, name: t.name,
version: t.version, version: t.version,
description: t.description, description: t.description,
css: t.css, css: t.css,
clientScripts: t.clientScripts clientScripts: t.clientScripts
})) }))
} }
getBuiltInThemes () { getBuiltInThemes () {
@ -416,13 +415,13 @@ class ServerConfigManager {
getRegisteredPlugins () { getRegisteredPlugins () {
return PluginManager.Instance.getRegisteredPlugins() return PluginManager.Instance.getRegisteredPlugins()
.map(p => ({ .map(p => ({
npmName: PluginModel.buildNpmName(p.name, p.type), npmName: PluginModel.buildNpmName(p.name, p.type),
name: p.name, name: p.name,
version: p.version, version: p.version,
description: p.description, description: p.description,
clientScripts: p.clientScripts clientScripts: p.clientScripts
})) }))
} }
getEnabledResolutions (type: 'vod' | 'live') { getEnabledResolutions (type: 'vod' | 'live') {
@ -431,8 +430,8 @@ class ServerConfigManager {
: CONFIG.LIVE.TRANSCODING : CONFIG.LIVE.TRANSCODING
return Object.keys(transcoding.RESOLUTIONS) return Object.keys(transcoding.RESOLUTIONS)
.filter(key => transcoding.ENABLED && transcoding.RESOLUTIONS[key] === true) .filter(key => transcoding.ENABLED && transcoding.RESOLUTIONS[key] === true)
.map(r => parseInt(r, 10) as VideoResolutionType) .map(r => parseInt(r, 10) as VideoResolutionType)
} }
private getIdAndPassAuthPlugins () { private getIdAndPassAuthPlugins () {

View file

@ -2,15 +2,18 @@ import { forceNumber, hasUserRight, USER_ROLE_LABELS } from '@peertube/peertube-
import { import {
AbuseState, AbuseState,
MyUser, MyUser,
NSFWFlag,
User, User,
UserAdminFlag, UserAdminFlag,
UserRightType, UserRightType,
UserRole,
VideoPlaylistType, VideoPlaylistType,
type NSFWPolicyType, type NSFWPolicyType,
type UserAdminFlagType, type UserAdminFlagType,
type UserRoleType, type UserRoleType
UserRole
} from '@peertube/peertube-models' } from '@peertube/peertube-models'
import { isNSFWFlagsValid } from '@server/helpers/custom-validators/videos.js'
import { CONFIG } from '@server/initializers/config.js'
import { TokensCache } from '@server/lib/auth/tokens-cache.js' import { TokensCache } from '@server/lib/auth/tokens-cache.js'
import { LiveQuotaStore } from '@server/lib/live/index.js' import { LiveQuotaStore } from '@server/lib/live/index.js'
import { import {
@ -75,9 +78,8 @@ import { VideoImportModel } from '../video/video-import.js'
import { VideoLiveModel } from '../video/video-live.js' import { VideoLiveModel } from '../video/video-live.js'
import { VideoPlaylistModel } from '../video/video-playlist.js' import { VideoPlaylistModel } from '../video/video-playlist.js'
import { VideoModel } from '../video/video.js' import { VideoModel } from '../video/video.js'
import { UserNotificationSettingModel } from './user-notification-setting.js'
import { UserExportModel } from './user-export.js' import { UserExportModel } from './user-export.js'
import { isNSFWFlagsValid } from '@server/helpers/custom-validators/videos.js' import { UserNotificationSettingModel } from './user-notification-setting.js'
enum ScopeNames { enum ScopeNames {
FOR_ME_API = 'FOR_ME_API', FOR_ME_API = 'FOR_ME_API',
@ -999,10 +1001,22 @@ export class UserModel extends SequelizeModel<UserModel> {
emailVerified: this.emailVerified, emailVerified: this.emailVerified,
nsfwPolicy: this.nsfwPolicy, nsfwPolicy: this.nsfwPolicy,
nsfwFlagsDisplayed: this.nsfwFlagsDisplayed,
nsfwFlagsHidden: this.nsfwFlagsHidden, nsfwFlagsDisplayed: CONFIG.NSFW_FLAGS_SETTINGS.ENABLED
nsfwFlagsWarned: this.nsfwFlagsWarned, ? this.nsfwFlagsDisplayed
nsfwFlagsBlurred: this.nsfwFlagsBlurred, : NSFWFlag.NONE,
nsfwFlagsHidden: CONFIG.NSFW_FLAGS_SETTINGS.ENABLED
? this.nsfwFlagsHidden
: NSFWFlag.NONE,
nsfwFlagsWarned: CONFIG.NSFW_FLAGS_SETTINGS.ENABLED
? this.nsfwFlagsWarned
: NSFWFlag.NONE,
nsfwFlagsBlurred: CONFIG.NSFW_FLAGS_SETTINGS.ENABLED
? this.nsfwFlagsBlurred
: NSFWFlag.NONE,
p2pEnabled: this.p2pEnabled, p2pEnabled: this.p2pEnabled,