From: Chocobozzz Date: Thu, 21 Feb 2019 14:44:12 +0000 (+0100) Subject: Add NSFW info in about page X-Git-Tag: v1.3.0-rc.1~158 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c8000975d361fae166a6ebecac5005238e14d4c9;p=oweals%2Fpeertube.git Add NSFW info in about page --- 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 @@
{{ shortDescription }}
+ +
This instance is dedicated to sensitive/NSFW content.
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 @@ .short-description, .description, .terms, .signup { margin-bottom: 30px; } + +.short-description .dedicated-to-nsfw { + margin-top: 20px; + font-weight: $font-semibold; +} 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 { return this.serverService.getConfig().email.enabled && this.serverService.getConfig().contactForm.enabled } + get isNSFW () { + return this.serverService.getConfig().instance.isNSFW + } + ngOnInit () { this.instanceService.getAbout() .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 @@
+ + + + + +
Default NSFW/sensitive videos policy (can be redefined by the users){{ buildNSFWLabel() }}
{{ feature.label }} 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 @@ 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('
') } - } 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 @@ 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() 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 @@ import './client' import './fetch' -import './helpers' import './refresher' +import './helpers' import './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 @@ 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() 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 @@ 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 }