Add isNSFW instance configuration key
This commit is contained in:
parent
1aabcae7e3
commit
f8802489bb
|
@ -44,6 +44,15 @@
|
||||||
<div *ngIf="formErrors.instance.terms" class="form-error">{{ formErrors.instance.terms }}</div>
|
<div *ngIf="formErrors.instance.terms" class="form-error">{{ formErrors.instance.terms }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<my-peertube-checkbox
|
||||||
|
inputName="instanceIsNSFW" formControlName="isNSFW"
|
||||||
|
i18n-labelText labelText="Dedicated to sensitive or NSFW content"
|
||||||
|
i18n-helpHtml helpHtml="Enabling it will allow other administrators to know that you are mainly federating sensitive content.<br /><br />
|
||||||
|
Moreover, the NSFW checkbox on video upload will be automatically checked by default."
|
||||||
|
></my-peertube-checkbox>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label i18n for="instanceDefaultClientRoute">Default client route</label>
|
<label i18n for="instanceDefaultClientRoute">Default client route</label>
|
||||||
<div class="peertube-select-container">
|
<div class="peertube-select-container">
|
||||||
|
|
|
@ -66,6 +66,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
|
||||||
description: null,
|
description: null,
|
||||||
terms: null,
|
terms: null,
|
||||||
defaultClientRoute: null,
|
defaultClientRoute: null,
|
||||||
|
isNSFW: false,
|
||||||
defaultNSFWPolicy: null,
|
defaultNSFWPolicy: null,
|
||||||
customizations: {
|
customizations: {
|
||||||
javascript: null,
|
javascript: null,
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { Inject, Injectable, LOCALE_ID } from '@angular/core'
|
||||||
import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
|
import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
|
||||||
import { Observable, of, ReplaySubject } from 'rxjs'
|
import { Observable, of, ReplaySubject } from 'rxjs'
|
||||||
import { getCompleteLocale, ServerConfig } from '../../../../../shared'
|
import { getCompleteLocale, ServerConfig } from '../../../../../shared'
|
||||||
import { About } from '../../../../../shared/models/server/about.model'
|
|
||||||
import { environment } from '../../../environments/environment'
|
import { environment } from '../../../environments/environment'
|
||||||
import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos'
|
import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos'
|
||||||
import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n'
|
import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n'
|
||||||
|
@ -32,6 +31,7 @@ export class ServerService {
|
||||||
shortDescription: 'PeerTube, a federated (ActivityPub) video streaming platform ' +
|
shortDescription: 'PeerTube, a federated (ActivityPub) video streaming platform ' +
|
||||||
'using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.',
|
'using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.',
|
||||||
defaultClientRoute: '',
|
defaultClientRoute: '',
|
||||||
|
isNSFW: false,
|
||||||
defaultNSFWPolicy: 'do_not_list' as 'do_not_list',
|
defaultNSFWPolicy: 'do_not_list' as 'do_not_list',
|
||||||
customizations: {
|
customizations: {
|
||||||
javascript: '',
|
javascript: '',
|
||||||
|
|
|
@ -163,7 +163,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
|
||||||
}
|
}
|
||||||
|
|
||||||
const privacy = this.firstStepPrivacyId.toString()
|
const privacy = this.firstStepPrivacyId.toString()
|
||||||
const nsfw = false
|
const nsfw = this.serverService.getConfig().instance.isNSFW
|
||||||
const waitTranscoding = true
|
const waitTranscoding = true
|
||||||
const commentsEnabled = true
|
const commentsEnabled = true
|
||||||
const downloadEnabled = true
|
const downloadEnabled = true
|
||||||
|
|
|
@ -163,6 +163,10 @@ instance:
|
||||||
description: 'Welcome to this PeerTube instance!' # Support markdown
|
description: 'Welcome to this PeerTube instance!' # Support markdown
|
||||||
terms: 'No terms for now.' # Support markdown
|
terms: 'No terms for now.' # Support markdown
|
||||||
default_client_route: '/videos/trending'
|
default_client_route: '/videos/trending'
|
||||||
|
# Whether or not the instance is dedicated to NSFW content
|
||||||
|
# Enabling it will allow other administrators to know that you are mainly federating sensitive content
|
||||||
|
# Moreover, the NSFW checkbox on video upload will be automatically checked by default
|
||||||
|
is_nsfw: false
|
||||||
# By default, "do_not_list" or "blur" or "display" NSFW videos
|
# By default, "do_not_list" or "blur" or "display" NSFW videos
|
||||||
# Could be overridden per user with a setting
|
# Could be overridden per user with a setting
|
||||||
default_nsfw_policy: 'do_not_list'
|
default_nsfw_policy: 'do_not_list'
|
||||||
|
|
|
@ -177,6 +177,10 @@ instance:
|
||||||
description: '' # Support markdown
|
description: '' # Support markdown
|
||||||
terms: '' # Support markdown
|
terms: '' # Support markdown
|
||||||
default_client_route: '/videos/trending'
|
default_client_route: '/videos/trending'
|
||||||
|
# Whether or not the instance is dedicated to NSFW content
|
||||||
|
# Enabling it will allow other administrators to know that you are mainly federating sensitive content
|
||||||
|
# Moreover, the NSFW checkbox on video upload will be automatically checked by default
|
||||||
|
is_nsfw: false
|
||||||
# By default, "do_not_list" or "blur" or "display" NSFW videos
|
# By default, "do_not_list" or "blur" or "display" NSFW videos
|
||||||
# Could be overridden per user with a setting
|
# Could be overridden per user with a setting
|
||||||
default_nsfw_policy: 'do_not_list'
|
default_nsfw_policy: 'do_not_list'
|
||||||
|
|
|
@ -58,6 +58,7 @@ async function getConfig (req: express.Request, res: express.Response) {
|
||||||
name: CONFIG.INSTANCE.NAME,
|
name: CONFIG.INSTANCE.NAME,
|
||||||
shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
|
shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
|
||||||
defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE,
|
defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE,
|
||||||
|
isNSFW: CONFIG.INSTANCE.IS_NSFW,
|
||||||
defaultNSFWPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
|
defaultNSFWPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
|
||||||
customizations: {
|
customizations: {
|
||||||
javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT,
|
javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT,
|
||||||
|
@ -134,7 +135,7 @@ async function getConfig (req: express.Request, res: express.Response) {
|
||||||
return res.json(json)
|
return res.json(json)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAbout (req: express.Request, res: express.Response, next: express.NextFunction) {
|
function getAbout (req: express.Request, res: express.Response) {
|
||||||
const about: About = {
|
const about: About = {
|
||||||
instance: {
|
instance: {
|
||||||
name: CONFIG.INSTANCE.NAME,
|
name: CONFIG.INSTANCE.NAME,
|
||||||
|
@ -147,13 +148,13 @@ function getAbout (req: express.Request, res: express.Response, next: express.Ne
|
||||||
return res.json(about).end()
|
return res.json(about).end()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
|
async function getCustomConfig (req: express.Request, res: express.Response) {
|
||||||
const data = customConfig()
|
const data = customConfig()
|
||||||
|
|
||||||
return res.json(data).end()
|
return res.json(data).end()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
|
async function deleteCustomConfig (req: express.Request, res: express.Response) {
|
||||||
await remove(CONFIG.CUSTOM_FILE)
|
await remove(CONFIG.CUSTOM_FILE)
|
||||||
|
|
||||||
auditLogger.delete(getAuditIdFromRes(res), new CustomConfigAuditView(customConfig()))
|
auditLogger.delete(getAuditIdFromRes(res), new CustomConfigAuditView(customConfig()))
|
||||||
|
@ -166,7 +167,7 @@ async function deleteCustomConfig (req: express.Request, res: express.Response,
|
||||||
return res.json(data).end()
|
return res.json(data).end()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function updateCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
|
async function updateCustomConfig (req: express.Request, res: express.Response) {
|
||||||
const oldCustomConfigAuditKeys = new CustomConfigAuditView(customConfig())
|
const oldCustomConfigAuditKeys = new CustomConfigAuditView(customConfig())
|
||||||
|
|
||||||
// camelCase to snake_case key + Force number conversion
|
// camelCase to snake_case key + Force number conversion
|
||||||
|
@ -203,6 +204,7 @@ function customConfig (): CustomConfig {
|
||||||
shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
|
shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
|
||||||
description: CONFIG.INSTANCE.DESCRIPTION,
|
description: CONFIG.INSTANCE.DESCRIPTION,
|
||||||
terms: CONFIG.INSTANCE.TERMS,
|
terms: CONFIG.INSTANCE.TERMS,
|
||||||
|
isNSFW: CONFIG.INSTANCE.IS_NSFW,
|
||||||
defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE,
|
defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE,
|
||||||
defaultNSFWPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
|
defaultNSFWPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
|
||||||
customizations: {
|
customizations: {
|
||||||
|
|
|
@ -23,7 +23,7 @@ function checkMissedConfig () {
|
||||||
'import.videos.http.enabled', 'import.videos.torrent.enabled',
|
'import.videos.http.enabled', 'import.videos.torrent.enabled',
|
||||||
'trending.videos.interval_days',
|
'trending.videos.interval_days',
|
||||||
'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route',
|
'instance.name', 'instance.short_description', 'instance.description', 'instance.terms', 'instance.default_client_route',
|
||||||
'instance.default_nsfw_policy', 'instance.robots', 'instance.securitytxt',
|
'instance.is_nsfw', 'instance.default_nsfw_policy', 'instance.robots', 'instance.securitytxt',
|
||||||
'services.twitter.username', 'services.twitter.whitelisted'
|
'services.twitter.username', 'services.twitter.whitelisted'
|
||||||
]
|
]
|
||||||
const requiredAlternatives = [
|
const requiredAlternatives = [
|
||||||
|
|
|
@ -288,6 +288,7 @@ const CONFIG = {
|
||||||
get SHORT_DESCRIPTION () { return config.get<string>('instance.short_description') },
|
get SHORT_DESCRIPTION () { return config.get<string>('instance.short_description') },
|
||||||
get DESCRIPTION () { return config.get<string>('instance.description') },
|
get DESCRIPTION () { return config.get<string>('instance.description') },
|
||||||
get TERMS () { return config.get<string>('instance.terms') },
|
get TERMS () { return config.get<string>('instance.terms') },
|
||||||
|
get IS_NSFW () { return config.get<boolean>('instance.is_nsfw') },
|
||||||
get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') },
|
get DEFAULT_CLIENT_ROUTE () { return config.get<string>('instance.default_client_route') },
|
||||||
get DEFAULT_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') },
|
get DEFAULT_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') },
|
||||||
CUSTOMIZATIONS: {
|
CUSTOMIZATIONS: {
|
||||||
|
|
|
@ -19,6 +19,7 @@ describe('Test config API validators', function () {
|
||||||
shortDescription: 'my short description',
|
shortDescription: 'my short description',
|
||||||
description: 'my super description',
|
description: 'my super description',
|
||||||
terms: 'my super terms',
|
terms: 'my super terms',
|
||||||
|
isNSFW: true,
|
||||||
defaultClientRoute: '/videos/recently-added',
|
defaultClientRoute: '/videos/recently-added',
|
||||||
defaultNSFWPolicy: 'blur',
|
defaultNSFWPolicy: 'blur',
|
||||||
customizations: {
|
customizations: {
|
||||||
|
|
|
@ -30,6 +30,7 @@ function checkInitialConfig (data: CustomConfig) {
|
||||||
expect(data.instance.description).to.equal('Welcome to this PeerTube instance!')
|
expect(data.instance.description).to.equal('Welcome to this PeerTube instance!')
|
||||||
expect(data.instance.terms).to.equal('No terms for now.')
|
expect(data.instance.terms).to.equal('No terms for now.')
|
||||||
expect(data.instance.defaultClientRoute).to.equal('/videos/trending')
|
expect(data.instance.defaultClientRoute).to.equal('/videos/trending')
|
||||||
|
expect(data.instance.isNSFW).to.be.false
|
||||||
expect(data.instance.defaultNSFWPolicy).to.equal('display')
|
expect(data.instance.defaultNSFWPolicy).to.equal('display')
|
||||||
expect(data.instance.customizations.css).to.be.empty
|
expect(data.instance.customizations.css).to.be.empty
|
||||||
expect(data.instance.customizations.javascript).to.be.empty
|
expect(data.instance.customizations.javascript).to.be.empty
|
||||||
|
@ -69,6 +70,7 @@ function checkUpdatedConfig (data: CustomConfig) {
|
||||||
expect(data.instance.description).to.equal('my super description')
|
expect(data.instance.description).to.equal('my super description')
|
||||||
expect(data.instance.terms).to.equal('my super terms')
|
expect(data.instance.terms).to.equal('my super terms')
|
||||||
expect(data.instance.defaultClientRoute).to.equal('/videos/recently-added')
|
expect(data.instance.defaultClientRoute).to.equal('/videos/recently-added')
|
||||||
|
expect(data.instance.isNSFW).to.be.true
|
||||||
expect(data.instance.defaultNSFWPolicy).to.equal('blur')
|
expect(data.instance.defaultNSFWPolicy).to.equal('blur')
|
||||||
expect(data.instance.customizations.javascript).to.equal('alert("coucou")')
|
expect(data.instance.customizations.javascript).to.equal('alert("coucou")')
|
||||||
expect(data.instance.customizations.css).to.equal('body { background-color: red; }')
|
expect(data.instance.customizations.css).to.equal('body { background-color: red; }')
|
||||||
|
@ -163,6 +165,7 @@ describe('Test config', function () {
|
||||||
description: 'my super description',
|
description: 'my super description',
|
||||||
terms: 'my super terms',
|
terms: 'my super terms',
|
||||||
defaultClientRoute: '/videos/recently-added',
|
defaultClientRoute: '/videos/recently-added',
|
||||||
|
isNSFW: true,
|
||||||
defaultNSFWPolicy: 'blur' as 'blur',
|
defaultNSFWPolicy: 'blur' as 'blur',
|
||||||
customizations: {
|
customizations: {
|
||||||
javascript: 'alert("coucou")',
|
javascript: 'alert("coucou")',
|
||||||
|
|
|
@ -6,6 +6,7 @@ export interface CustomConfig {
|
||||||
shortDescription: string
|
shortDescription: string
|
||||||
description: string
|
description: string
|
||||||
terms: string
|
terms: string
|
||||||
|
isNSFW: boolean
|
||||||
defaultClientRoute: string
|
defaultClientRoute: string
|
||||||
defaultNSFWPolicy: NSFWPolicyType
|
defaultNSFWPolicy: NSFWPolicyType
|
||||||
customizations: {
|
customizations: {
|
||||||
|
|
|
@ -8,6 +8,7 @@ export interface ServerConfig {
|
||||||
name: string
|
name: string
|
||||||
shortDescription: string
|
shortDescription: string
|
||||||
defaultClientRoute: string
|
defaultClientRoute: string
|
||||||
|
isNSFW: boolean
|
||||||
defaultNSFWPolicy: NSFWPolicyType
|
defaultNSFWPolicy: NSFWPolicyType
|
||||||
customizations: {
|
customizations: {
|
||||||
javascript: string
|
javascript: string
|
||||||
|
|
|
@ -52,6 +52,7 @@ function updateCustomSubConfig (url: string, token: string, newConfig: any) {
|
||||||
description: 'my super description',
|
description: 'my super description',
|
||||||
terms: 'my super terms',
|
terms: 'my super terms',
|
||||||
defaultClientRoute: '/videos/recently-added',
|
defaultClientRoute: '/videos/recently-added',
|
||||||
|
isNSFW: true,
|
||||||
defaultNSFWPolicy: 'blur',
|
defaultNSFWPolicy: 'blur',
|
||||||
customizations: {
|
customizations: {
|
||||||
javascript: 'alert("coucou")',
|
javascript: 'alert("coucou")',
|
||||||
|
|
Loading…
Reference in New Issue