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>
|
||||
|
||||
<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">
|
||||
<label i18n for="instanceDefaultClientRoute">Default client route</label>
|
||||
<div class="peertube-select-container">
|
||||
|
|
|
@ -66,6 +66,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
|
|||
description: null,
|
||||
terms: null,
|
||||
defaultClientRoute: null,
|
||||
isNSFW: false,
|
||||
defaultNSFWPolicy: null,
|
||||
customizations: {
|
||||
javascript: null,
|
||||
|
|
|
@ -4,7 +4,6 @@ import { Inject, Injectable, LOCALE_ID } from '@angular/core'
|
|||
import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
|
||||
import { Observable, of, ReplaySubject } from 'rxjs'
|
||||
import { getCompleteLocale, ServerConfig } from '../../../../../shared'
|
||||
import { About } from '../../../../../shared/models/server/about.model'
|
||||
import { environment } from '../../../environments/environment'
|
||||
import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos'
|
||||
import { isDefaultLocale, peertubeTranslate } from '../../../../../shared/models/i18n'
|
||||
|
@ -32,6 +31,7 @@ export class ServerService {
|
|||
shortDescription: 'PeerTube, a federated (ActivityPub) video streaming platform ' +
|
||||
'using P2P (BitTorrent) directly in the web browser with WebTorrent and Angular.',
|
||||
defaultClientRoute: '',
|
||||
isNSFW: false,
|
||||
defaultNSFWPolicy: 'do_not_list' as 'do_not_list',
|
||||
customizations: {
|
||||
javascript: '',
|
||||
|
|
|
@ -163,7 +163,7 @@ export class VideoUploadComponent extends VideoSend implements OnInit, OnDestroy
|
|||
}
|
||||
|
||||
const privacy = this.firstStepPrivacyId.toString()
|
||||
const nsfw = false
|
||||
const nsfw = this.serverService.getConfig().instance.isNSFW
|
||||
const waitTranscoding = true
|
||||
const commentsEnabled = true
|
||||
const downloadEnabled = true
|
||||
|
|
|
@ -163,6 +163,10 @@ instance:
|
|||
description: 'Welcome to this PeerTube instance!' # Support markdown
|
||||
terms: 'No terms for now.' # Support markdown
|
||||
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
|
||||
# Could be overridden per user with a setting
|
||||
default_nsfw_policy: 'do_not_list'
|
||||
|
|
|
@ -177,6 +177,10 @@ instance:
|
|||
description: '' # Support markdown
|
||||
terms: '' # Support markdown
|
||||
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
|
||||
# Could be overridden per user with a setting
|
||||
default_nsfw_policy: 'do_not_list'
|
||||
|
|
|
@ -58,6 +58,7 @@ async function getConfig (req: express.Request, res: express.Response) {
|
|||
name: CONFIG.INSTANCE.NAME,
|
||||
shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
|
||||
defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE,
|
||||
isNSFW: CONFIG.INSTANCE.IS_NSFW,
|
||||
defaultNSFWPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
|
||||
customizations: {
|
||||
javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT,
|
||||
|
@ -134,7 +135,7 @@ async function getConfig (req: express.Request, res: express.Response) {
|
|||
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 = {
|
||||
instance: {
|
||||
name: CONFIG.INSTANCE.NAME,
|
||||
|
@ -147,13 +148,13 @@ function getAbout (req: express.Request, res: express.Response, next: express.Ne
|
|||
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()
|
||||
|
||||
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)
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
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())
|
||||
|
||||
// camelCase to snake_case key + Force number conversion
|
||||
|
@ -203,6 +204,7 @@ function customConfig (): CustomConfig {
|
|||
shortDescription: CONFIG.INSTANCE.SHORT_DESCRIPTION,
|
||||
description: CONFIG.INSTANCE.DESCRIPTION,
|
||||
terms: CONFIG.INSTANCE.TERMS,
|
||||
isNSFW: CONFIG.INSTANCE.IS_NSFW,
|
||||
defaultClientRoute: CONFIG.INSTANCE.DEFAULT_CLIENT_ROUTE,
|
||||
defaultNSFWPolicy: CONFIG.INSTANCE.DEFAULT_NSFW_POLICY,
|
||||
customizations: {
|
||||
|
|
|
@ -23,7 +23,7 @@ function checkMissedConfig () {
|
|||
'import.videos.http.enabled', 'import.videos.torrent.enabled',
|
||||
'trending.videos.interval_days',
|
||||
'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'
|
||||
]
|
||||
const requiredAlternatives = [
|
||||
|
|
|
@ -288,6 +288,7 @@ const CONFIG = {
|
|||
get SHORT_DESCRIPTION () { return config.get<string>('instance.short_description') },
|
||||
get DESCRIPTION () { return config.get<string>('instance.description') },
|
||||
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_NSFW_POLICY () { return config.get<NSFWPolicyType>('instance.default_nsfw_policy') },
|
||||
CUSTOMIZATIONS: {
|
||||
|
|
|
@ -19,6 +19,7 @@ describe('Test config API validators', function () {
|
|||
shortDescription: 'my short description',
|
||||
description: 'my super description',
|
||||
terms: 'my super terms',
|
||||
isNSFW: true,
|
||||
defaultClientRoute: '/videos/recently-added',
|
||||
defaultNSFWPolicy: 'blur',
|
||||
customizations: {
|
||||
|
|
|
@ -30,6 +30,7 @@ function checkInitialConfig (data: CustomConfig) {
|
|||
expect(data.instance.description).to.equal('Welcome to this PeerTube instance!')
|
||||
expect(data.instance.terms).to.equal('No terms for now.')
|
||||
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.customizations.css).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.terms).to.equal('my super terms')
|
||||
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.customizations.javascript).to.equal('alert("coucou")')
|
||||
expect(data.instance.customizations.css).to.equal('body { background-color: red; }')
|
||||
|
@ -163,6 +165,7 @@ describe('Test config', function () {
|
|||
description: 'my super description',
|
||||
terms: 'my super terms',
|
||||
defaultClientRoute: '/videos/recently-added',
|
||||
isNSFW: true,
|
||||
defaultNSFWPolicy: 'blur' as 'blur',
|
||||
customizations: {
|
||||
javascript: 'alert("coucou")',
|
||||
|
|
|
@ -6,6 +6,7 @@ export interface CustomConfig {
|
|||
shortDescription: string
|
||||
description: string
|
||||
terms: string
|
||||
isNSFW: boolean
|
||||
defaultClientRoute: string
|
||||
defaultNSFWPolicy: NSFWPolicyType
|
||||
customizations: {
|
||||
|
|
|
@ -8,6 +8,7 @@ export interface ServerConfig {
|
|||
name: string
|
||||
shortDescription: string
|
||||
defaultClientRoute: string
|
||||
isNSFW: boolean
|
||||
defaultNSFWPolicy: NSFWPolicyType
|
||||
customizations: {
|
||||
javascript: string
|
||||
|
|
|
@ -52,6 +52,7 @@ function updateCustomSubConfig (url: string, token: string, newConfig: any) {
|
|||
description: 'my super description',
|
||||
terms: 'my super terms',
|
||||
defaultClientRoute: '/videos/recently-added',
|
||||
isNSFW: true,
|
||||
defaultNSFWPolicy: 'blur',
|
||||
customizations: {
|
||||
javascript: 'alert("coucou")',
|
||||
|
|
Loading…
Reference in New Issue