From f8802489bbc2c0363b5668e47de7c35f573342e1 Mon Sep 17 00:00:00 2001
From: Chocobozzz <me@florianbigard.com>
Date: Wed, 20 Feb 2019 15:36:43 +0100
Subject: Add isNSFW instance configuration key

---
 .../config/edit-custom-config/edit-custom-config.component.html  | 9 +++++++++
 .../config/edit-custom-config/edit-custom-config.component.ts    | 1 +
 client/src/app/core/server/server.service.ts                     | 2 +-
 .../+video-edit/video-add-components/video-upload.component.ts   | 2 +-
 4 files changed, 12 insertions(+), 2 deletions(-)

(limited to 'client/src')

diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
index 52eb00d93..b7d95bc22 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
@@ -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">
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
index 654a076b0..45605e0fe 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
@@ -66,6 +66,7 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
         description: null,
         terms: null,
         defaultClientRoute: null,
+        isNSFW: false,
         defaultNSFWPolicy: null,
         customizations: {
           javascript: null,
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts
index c868ccdcc..10acf6e72 100644
--- a/client/src/app/core/server/server.service.ts
+++ b/client/src/app/core/server/server.service.ts
@@ -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: '',
diff --git a/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts
index 9cadf52cb..7399f39ee 100644
--- a/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts
+++ b/client/src/app/videos/+video-edit/video-add-components/video-upload.component.ts
@@ -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
-- 
cgit v1.2.3