From 16a173bbc98509705105eec8189fa5543d9673c7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 18 Nov 2020 15:55:19 +0100 Subject: Automatically enable videos auto block on signup --- .../edit-custom-config.component.ts | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts') 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 d442df0e3..7db65d038 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 @@ -20,6 +20,7 @@ import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@a import { FormReactive, FormValidatorService, SelectOptionsItem } from '@app/shared/shared-forms' import { NgbNav } from '@ng-bootstrap/ng-bootstrap' import { CustomConfig, ServerConfig } from '@shared/models' +import { pairwise } from 'rxjs/operators' @Component({ selector: 'my-edit-custom-config', @@ -41,6 +42,8 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A languageItems: SelectOptionsItem[] = [] categoryItems: SelectOptionsItem[] = [] + signupAlertMessage: string + private serverConfig: ServerConfig constructor ( @@ -293,7 +296,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A this.buildForm(formGroupData) this.loadForm() + this.checkTranscodingFields() + this.checkSignupField() } ngAfterViewChecked () { @@ -428,4 +433,27 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit, A } }) } + + private checkSignupField () { + const signupControl = this.form.get('signup.enabled') + + signupControl.valueChanges + .pipe(pairwise()) + .subscribe(([ oldValue, newValue ]) => { + if (oldValue !== true && newValue === true) { + // tslint:disable:max-line-length + this.signupAlertMessage = $localize`You enabled signup: we automatically enabled the "Block new videos automatically" checkbox of the "Videos" section just below.` + + this.form.patchValue({ + autoBlacklist: { + videos: { + ofUsers: { + enabled: true + } + } + } + }) + } + }) + } } -- cgit v1.2.3