aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-02-21 15:44:12 +0100
committerChocobozzz <me@florianbigard.com>2019-02-21 15:51:28 +0100
commitc8000975d361fae166a6ebecac5005238e14d4c9 (patch)
tree67d7da38abc6c4d9ceb4d120088d499309f69e30
parente359e88b08476041c3c52db02fb3ca4e5ee296ea (diff)
downloadPeerTube-c8000975d361fae166a6ebecac5005238e14d4c9.tar.gz
PeerTube-c8000975d361fae166a6ebecac5005238e14d4c9.tar.zst
PeerTube-c8000975d361fae166a6ebecac5005238e14d4c9.zip
Add NSFW info in about page
-rw-r--r--client/src/app/+about/about-instance/about-instance.component.html2
-rw-r--r--client/src/app/+about/about-instance/about-instance.component.scss5
-rw-r--r--client/src/app/+about/about-instance/about-instance.component.ts4
-rw-r--r--client/src/app/shared/instance/instance-features-table.component.html6
-rw-r--r--client/src/app/shared/instance/instance-features-table.component.ts10
-rw-r--r--server/tests/api/activitypub/fetch.ts3
-rw-r--r--server/tests/api/activitypub/index.ts2
-rw-r--r--server/tests/api/activitypub/security.ts3
-rw-r--r--shared/utils/miscs/sql.ts22
9 files changed, 53 insertions, 4 deletions
diff --git a/client/src/app/+about/about-instance/about-instance.component.html b/client/src/app/+about/about-instance/about-instance.component.html
index 83376b6f6..7c27ec760 100644
--- a/client/src/app/+about/about-instance/about-instance.component.html
+++ b/client/src/app/+about/about-instance/about-instance.component.html
@@ -8,6 +8,8 @@
8 8
9 <div class="short-description"> 9 <div class="short-description">
10 <div>{{ shortDescription }}</div> 10 <div>{{ shortDescription }}</div>
11
12 <div *ngIf="isNSFW" class="dedicated-to-nsfw">This instance is dedicated to sensitive/NSFW content.</div>
11 </div> 13 </div>
12 14
13 <div class="description"> 15 <div class="description">
diff --git a/client/src/app/+about/about-instance/about-instance.component.scss b/client/src/app/+about/about-instance/about-instance.component.scss
index 75cf57322..3aba7fe42 100644
--- a/client/src/app/+about/about-instance/about-instance.component.scss
+++ b/client/src/app/+about/about-instance/about-instance.component.scss
@@ -26,3 +26,8 @@
26.short-description, .description, .terms, .signup { 26.short-description, .description, .terms, .signup {
27 margin-bottom: 30px; 27 margin-bottom: 30px;
28} 28}
29
30.short-description .dedicated-to-nsfw {
31 margin-top: 20px;
32 font-weight: $font-semibold;
33}
diff --git a/client/src/app/+about/about-instance/about-instance.component.ts b/client/src/app/+about/about-instance/about-instance.component.ts
index c9eab44ab..4a63f5e38 100644
--- a/client/src/app/+about/about-instance/about-instance.component.ts
+++ b/client/src/app/+about/about-instance/about-instance.component.ts
@@ -33,6 +33,10 @@ export class AboutInstanceComponent implements OnInit {
33 return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled 33 return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled
34 } 34 }
35 35
36 get isNSFW () {
37 return this.serverService.getConfig().instance.isNSFW
38 }
39
36 ngOnInit () { 40 ngOnInit () {
37 this.instanceService.getAbout() 41 this.instanceService.getAbout()
38 .subscribe( 42 .subscribe(
diff --git a/client/src/app/shared/instance/instance-features-table.component.html b/client/src/app/shared/instance/instance-features-table.component.html
index 90046f409..2885f97e3 100644
--- a/client/src/app/shared/instance/instance-features-table.component.html
+++ b/client/src/app/shared/instance/instance-features-table.component.html
@@ -1,6 +1,12 @@
1<div class="feature-table"> 1<div class="feature-table">
2 2
3 <table class="table"> 3 <table class="table">
4 <tr>
5 <td i18n class="label">Default NSFW/sensitive videos policy (can be redefined by the users)</td>
6
7 <td class="value">{{ buildNSFWLabel() }}</td>
8 </tr>
9
4 <tr *ngFor="let feature of features"> 10 <tr *ngFor="let feature of features">
5 <td class="label">{{ feature.label }}</td> 11 <td class="label">{{ feature.label }}</td>
6 <td> 12 <td>
diff --git a/client/src/app/shared/instance/instance-features-table.component.ts b/client/src/app/shared/instance/instance-features-table.component.ts
index aaf0a6960..a4924a0d5 100644
--- a/client/src/app/shared/instance/instance-features-table.component.ts
+++ b/client/src/app/shared/instance/instance-features-table.component.ts
@@ -1,6 +1,7 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { ServerService } from '@app/core' 2import { ServerService } from '@app/core'
3import { I18n } from '@ngx-translate/i18n-polyfill' 3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { ServerConfig } from '../../../../../shared'
4 5
5@Component({ 6@Component({
6 selector: 'my-instance-features-table', 7 selector: 'my-instance-features-table',
@@ -33,6 +34,14 @@ export class InstanceFeaturesTableComponent implements OnInit {
33 }) 34 })
34 } 35 }
35 36
37 buildNSFWLabel () {
38 const policy = this.serverService.getConfig().instance.defaultNSFWPolicy
39
40 if (policy === 'do_not_list') return this.i18n('Hidden')
41 if (policy === 'blur') return this.i18n('Blurred with confirmation request')
42 if (policy === 'display') return this.i18n('Displayed')
43 }
44
36 private buildFeatures () { 45 private buildFeatures () {
37 const config = this.serverService.getConfig() 46 const config = this.serverService.getConfig()
38 47
@@ -87,5 +96,4 @@ export class InstanceFeaturesTableComponent implements OnInit {
87 96
88 this.quotaHelpIndication = lines.join('<br />') 97 this.quotaHelpIndication = lines.join('<br />')
89 } 98 }
90
91} 99}
diff --git a/server/tests/api/activitypub/fetch.ts b/server/tests/api/activitypub/fetch.ts
index 03609c1a9..5c617de10 100644
--- a/server/tests/api/activitypub/fetch.ts
+++ b/server/tests/api/activitypub/fetch.ts
@@ -3,6 +3,7 @@
3import 'mocha' 3import 'mocha'
4 4
5import { 5import {
6 closeAllSequelize,
6 createUser, 7 createUser,
7 doubleFollow, 8 doubleFollow,
8 flushAndRunMultipleServers, 9 flushAndRunMultipleServers,
@@ -79,6 +80,8 @@ describe('Test ActivityPub fetcher', function () {
79 after(async function () { 80 after(async function () {
80 killallServers(servers) 81 killallServers(servers)
81 82
83 await closeAllSequelize(servers)
84
82 // Keep the logs if the test failed 85 // Keep the logs if the test failed
83 if (this['ok']) { 86 if (this['ok']) {
84 await flushTests() 87 await flushTests()
diff --git a/server/tests/api/activitypub/index.ts b/server/tests/api/activitypub/index.ts
index 450053309..92bd6f660 100644
--- a/server/tests/api/activitypub/index.ts
+++ b/server/tests/api/activitypub/index.ts
@@ -1,5 +1,5 @@
1import './client' 1import './client'
2import './fetch' 2import './fetch'
3import './helpers'
4import './refresher' 3import './refresher'
4import './helpers'
5import './security' 5import './security'
diff --git a/server/tests/api/activitypub/security.ts b/server/tests/api/activitypub/security.ts
index 342ae0fa1..b78504073 100644
--- a/server/tests/api/activitypub/security.ts
+++ b/server/tests/api/activitypub/security.ts
@@ -3,6 +3,7 @@
3import 'mocha' 3import 'mocha'
4 4
5import { 5import {
6 closeAllSequelize,
6 flushAndRunMultipleServers, 7 flushAndRunMultipleServers,
7 flushTests, 8 flushTests,
8 killallServers, 9 killallServers,
@@ -179,6 +180,8 @@ describe('Test ActivityPub security', function () {
179 after(async function () { 180 after(async function () {
180 killallServers(servers) 181 killallServers(servers)
181 182
183 await closeAllSequelize(servers)
184
182 // Keep the logs if the test failed 185 // Keep the logs if the test failed
183 if (this['ok']) { 186 if (this['ok']) {
184 await flushTests() 187 await flushTests()
diff --git a/shared/utils/miscs/sql.ts b/shared/utils/miscs/sql.ts
index 027f78131..bb3f63837 100644
--- a/shared/utils/miscs/sql.ts
+++ b/shared/utils/miscs/sql.ts
@@ -1,19 +1,27 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2 2
3let sequelizes: { [ id: number ]: Sequelize.Sequelize } = {}
4
3function getSequelize (serverNumber: number) { 5function getSequelize (serverNumber: number) {
6 if (sequelizes[serverNumber]) return sequelizes[serverNumber]
7
4 const dbname = 'peertube_test' + serverNumber 8 const dbname = 'peertube_test' + serverNumber
5 const username = 'peertube' 9 const username = 'peertube'
6 const password = 'peertube' 10 const password = 'peertube'
7 const host = 'localhost' 11 const host = 'localhost'
8 const port = 5432 12 const port = 5432
9 13
10 return new Sequelize(dbname, username, password, { 14 const seq = new Sequelize(dbname, username, password, {
11 dialect: 'postgres', 15 dialect: 'postgres',
12 host, 16 host,
13 port, 17 port,
14 operatorsAliases: false, 18 operatorsAliases: false,
15 logging: false 19 logging: false
16 }) 20 })
21
22 sequelizes[serverNumber] = seq
23
24 return seq
17} 25}
18 26
19function setActorField (serverNumber: number, to: string, field: string, value: string) { 27function setActorField (serverNumber: number, to: string, field: string, value: string) {
@@ -32,7 +40,17 @@ function setVideoField (serverNumber: number, uuid: string, field: string, value
32 return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options) 40 return seq.query(`UPDATE video SET "${field}" = '${value}' WHERE uuid = '${uuid}'`, options)
33} 41}
34 42
43async function closeAllSequelize (servers: any[]) {
44 for (let i = 1; i <= servers.length; i++) {
45 if (sequelizes[ i ]) {
46 await sequelizes[ i ].close()
47 delete sequelizes[ i ]
48 }
49 }
50}
51
35export { 52export {
36 setVideoField, 53 setVideoField,
37 setActorField 54 setActorField,
55 closeAllSequelize
38} 56}