]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / moderation / registration-list / process-registration-modal.component.ts
index fbe8deb41220941e4f3e8bd0d61afd6bed8e5abc..8f013cbd500884be1c4e531212b617b0478f9c94 100644 (file)
@@ -9,8 +9,7 @@ import { REGISTRATION_MODERATION_RESPONSE_VALIDATOR } from './process-registrati
 
 @Component({
   selector: 'my-process-registration-modal',
-  templateUrl: './process-registration-modal.component.html',
-  styleUrls: [ './process-registration-modal.component.scss' ]
+  templateUrl: './process-registration-modal.component.html'
 })
 export class ProcessRegistrationModalComponent extends FormReactive implements OnInit {
   @ViewChild('modal', { static: true }) modal: NgbModal
@@ -34,7 +33,8 @@ export class ProcessRegistrationModalComponent extends FormReactive implements O
 
   ngOnInit () {
     this.buildForm({
-      moderationResponse: REGISTRATION_MODERATION_RESPONSE_VALIDATOR
+      moderationResponse: REGISTRATION_MODERATION_RESPONSE_VALIDATOR,
+      preventEmailDelivery: null
     })
   }
 
@@ -50,6 +50,10 @@ export class ProcessRegistrationModalComponent extends FormReactive implements O
     this.processMode = mode
     this.registration = registration
 
+    this.form.patchValue({
+      preventEmailDelivery: !this.isEmailEnabled() || registration.emailVerified !== true
+    })
+
     this.openedModal = this.modalService.open(this.modal, { centered: true })
   }
 
@@ -77,31 +81,41 @@ export class ProcessRegistrationModalComponent extends FormReactive implements O
     return this.server.getHTMLConfig().email.enabled
   }
 
-  private acceptRegistration () {
-    this.registrationService.acceptRegistration(this.registration, this.form.value.moderationResponse)
-      .subscribe({
-        next: () => {
-          this.notifier.success($localize`${this.registration.username} account created`)
-
-          this.registrationProcessed.emit()
-          this.hide()
-        },
+  isPreventEmailDeliveryChecked () {
+    return this.form.value.preventEmailDelivery
+  }
 
-        error: err => this.notifier.error(err.message)
-      })
+  private acceptRegistration () {
+    this.registrationService.acceptRegistration({
+      registration: this.registration,
+      moderationResponse: this.form.value.moderationResponse,
+      preventEmailDelivery: this.form.value.preventEmailDelivery
+    }).subscribe({
+      next: () => {
+        this.notifier.success($localize`${this.registration.username} account created`)
+
+        this.registrationProcessed.emit()
+        this.hide()
+      },
+
+      error: err => this.notifier.error(err.message)
+    })
   }
 
   private rejectRegistration () {
-    this.registrationService.rejectRegistration(this.registration, this.form.value.moderationResponse)
-      .subscribe({
-        next: () => {
-          this.notifier.success($localize`${this.registration.username} registration rejected`)
-
-          this.registrationProcessed.emit()
-          this.hide()
-        },
-
-        error: err => this.notifier.error(err.message)
-      })
+    this.registrationService.rejectRegistration({
+      registration: this.registration,
+      moderationResponse: this.form.value.moderationResponse,
+      preventEmailDelivery: this.form.value.preventEmailDelivery
+    }).subscribe({
+      next: () => {
+        this.notifier.success($localize`${this.registration.username} registration rejected`)
+
+        this.registrationProcessed.emit()
+        this.hide()
+      },
+
+      error: err => this.notifier.error(err.message)
+    })
   }
 }