]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts
Add description to "remove" registration request
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / moderation / registration-list / process-registration-modal.component.ts
index fbe8deb41220941e4f3e8bd0d61afd6bed8e5abc..3a7e5dea138449e6710f54ce7d6fb665995dac6f 100644 (file)
@@ -34,7 +34,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 +51,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 +82,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)
+    })
   }
 }