Add NSFW info in about page
authorChocobozzz <me@florianbigard.com>
Thu, 21 Feb 2019 14:44:12 +0000 (15:44 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 21 Feb 2019 14:51:28 +0000 (15:51 +0100)
client/src/app/+about/about-instance/about-instance.component.html
client/src/app/+about/about-instance/about-instance.component.scss
client/src/app/+about/about-instance/about-instance.component.ts
client/src/app/shared/instance/instance-features-table.component.html
client/src/app/shared/instance/instance-features-table.component.ts
server/tests/api/activitypub/fetch.ts
server/tests/api/activitypub/index.ts
server/tests/api/activitypub/security.ts
shared/utils/miscs/sql.ts

index 83376b6f67183cd3b5f7a00414bad1bc6323f843..7c27ec7607f5cd277602df33322280228898be26 100644 (file)
@@ -8,6 +8,8 @@
 
     <div class="short-description">
       <div>{{ shortDescription }}</div>
+
+      <div *ngIf="isNSFW" class="dedicated-to-nsfw">This instance is dedicated to sensitive/NSFW content.</div>
     </div>
 
     <div class="description">
index 75cf573220df28e4fe45792f11010147a7f4c3ea..3aba7fe42ecd58df704c9bbd4f748b0da6fab2df 100644 (file)
@@ -26,3 +26,8 @@
 .short-description, .description, .terms, .signup {
   margin-bottom: 30px;
 }
+
+.short-description .dedicated-to-nsfw {
+  margin-top: 20px;
+  font-weight: $font-semibold;
+}
index c9eab44ab6efcf7e0170b54a446660a55d8a2df8..4a63f5e3843359caaded89929276ccba96c2615b 100644 (file)
@@ -33,6 +33,10 @@ export class AboutInstanceComponent implements OnInit {
     return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled
   }
 
+  get isNSFW () {
+    return this.serverService.getConfig().instance.isNSFW
+  }
+
   ngOnInit () {
     this.instanceService.getAbout()
       .subscribe(
index 90046f4094c59d4c1a97d2764db28c484a560d3b..2885f97e3ab17d9d4f25a2d84554500a30bfa8a6 100644 (file)
@@ -1,6 +1,12 @@
 <div class="feature-table">
 
   <table class="table">
+    <tr>
+      <td i18n class="label">Default NSFW/sensitive videos policy (can be redefined by the users)</td>
+
+      <td class="value">{{ buildNSFWLabel() }}</td>
+    </tr>
+
     <tr *ngFor="let feature of features">
       <td class="label">{{ feature.label }}</td>
       <td>
index aaf0a696014da22fa458c6c01f93feb8191772d8..a4924a0d5c2d224c0b7e74cbcded6ef917a92bc6 100644 (file)
@@ -1,6 +1,7 @@
 import { Component, OnInit } from '@angular/core'
 import { ServerService } from '@app/core'
 import { I18n } from '@ngx-translate/i18n-polyfill'
+import { ServerConfig } from '../../../../../shared'
 
 @Component({
   selector: 'my-instance-features-table',
@@ -33,6 +34,14 @@ export class InstanceFeaturesTableComponent implements OnInit {
         })
   }
 
+  buildNSFWLabel () {
+    const policy = this.serverService.getConfig().instance.defaultNSFWPolicy
+
+    if (policy === 'do_not_list') return this.i18n('Hidden')
+    if (policy === 'blur') return this.i18n('Blurred with confirmation request')
+    if (policy === 'display') return this.i18n('Displayed')
+  }
+
   private buildFeatures () {
     const config = this.serverService.getConfig()
 
@@ -87,5 +96,4 @@ export class InstanceFeaturesTableComponent implements OnInit {
 
     this.quotaHelpIndication = lines.join('<br />')
   }
-
 }
index 03609c1a977cad092f04c9d02dbd43c2fb2b2ebb..5c617de1008ccade89bdb0c22b65797057813fdb 100644 (file)
@@ -3,6 +3,7 @@
 import 'mocha'
 
 import {
+  closeAllSequelize,
   createUser,
   doubleFollow,
   flushAndRunMultipleServers,
@@ -79,6 +80,8 @@ describe('Test ActivityPub fetcher', function () {
   after(async function () {
     killallServers(servers)
 
+    await closeAllSequelize(servers)
+
     // Keep the logs if the test failed
     if (this['ok']) {
       await flushTests()
index 450053309d0ae6a20fa89b38e299216827b8fe5a..92bd6f6607a01101350836ec49cfc8ac55dbba4e 100644 (file)
@@ -1,5 +1,5 @@
 import './client'
 import './fetch'
-import './helpers'
 import './refresher'
+import './helpers'
 import './security'
index 342ae0fa13e346fcddef8f4c799123d3a6cee706..b7850407362d93f8bba168dc31590ac7a5d50b23 100644 (file)
@@ -3,6 +3,7 @@
 import 'mocha'
 
 import {
+  closeAllSequelize,
   flushAndRunMultipleServers,
   flushTests,
   killallServers,
@@ -179,6 +180,8 @@ describe('Test ActivityPub security', function () {
   after(async function () {
     killallServers(servers)
 
+    await closeAllSequelize(servers)
+
     // Keep the logs if the test failed
     if (this['ok']) {
       await flushTests()
index 027f781318cec2d3b69f79f7812b44001a095017..bb3f63837d62e8c9e27b86d9f2e064391189572d 100644 (file)
@@ -1,19 +1,27 @@
 import * as Sequelize from 'sequelize'
 
+let sequelizes: { [ id: number ]: Sequelize.Sequelize } = {}
+
 function getSequelize (serverNumber: number) {
+  if (sequelizes[serverNumber]) return sequelizes[serverNumber]
+
   const dbname = 'peertube_test' + serverNumber
   const username = 'peertube'
   const password = 'peertube'
   const host = 'localhost'
   const port = 5432
 
-  return new Sequelize(dbname, username, password, {
+  const seq = new Sequelize(dbname, username, password, {
     dialect: 'postgres',
     host,
     port,
     operatorsAliases: false,
     logging: false
   })
+
+  sequelizes[serverNumber] = seq
+
+  return seq
 }
 
 function setActorField (serverNumber: number, to: string, field: string, value: string) {
@@ -32,7 +40,17 @@ function setVideoField (serverNumber: number, uuid: string, field: string, value
   return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)
 }
 
+async function closeAllSequelize (servers: any[]) {
+  for (let i = 1; i <= servers.length; i++) {
+    if (sequelizes[ i ]) {
+      await sequelizes[ i ].close()
+      delete sequelizes[ i ]
+    }
+  }
+}
+
 export {
   setVideoField,
-  setActorField
+  setActorField,
+  closeAllSequelize
 }