aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/+admin/moderation/registration-list/admin-registration.service.ts22
-rw-r--r--client/src/app/+admin/moderation/registration-list/process-registration-modal.component.html13
-rw-r--r--client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts61
-rw-r--r--client/src/app/shared/form-validators/form-validator.model.ts2
4 files changed, 66 insertions, 32 deletions
diff --git a/client/src/app/+admin/moderation/registration-list/admin-registration.service.ts b/client/src/app/+admin/moderation/registration-list/admin-registration.service.ts
index 10e2938c7..a9f13cf2f 100644
--- a/client/src/app/+admin/moderation/registration-list/admin-registration.service.ts
+++ b/client/src/app/+admin/moderation/registration-list/admin-registration.service.ts
@@ -5,7 +5,7 @@ import { HttpClient, HttpParams } from '@angular/common/http'
5import { Injectable } from '@angular/core' 5import { Injectable } from '@angular/core'
6import { RestExtractor, RestPagination, RestService } from '@app/core' 6import { RestExtractor, RestPagination, RestService } from '@app/core'
7import { arrayify } from '@shared/core-utils' 7import { arrayify } from '@shared/core-utils'
8import { ResultList, UserRegistration } from '@shared/models' 8import { ResultList, UserRegistration, UserRegistrationUpdateState } from '@shared/models'
9import { environment } from '../../../../environments/environment' 9import { environment } from '../../../../environments/environment'
10 10
11@Injectable() 11@Injectable()
@@ -40,17 +40,29 @@ export class AdminRegistrationService {
40 ) 40 )
41 } 41 }
42 42
43 acceptRegistration (registration: UserRegistration, moderationResponse: string) { 43 acceptRegistration (options: {
44 registration: UserRegistration
45 moderationResponse: string
46 preventEmailDelivery: boolean
47 }) {
48 const { registration, moderationResponse, preventEmailDelivery } = options
49
44 const url = AdminRegistrationService.BASE_REGISTRATION_URL + '/' + registration.id + '/accept' 50 const url = AdminRegistrationService.BASE_REGISTRATION_URL + '/' + registration.id + '/accept'
45 const body = { moderationResponse } 51 const body: UserRegistrationUpdateState = { moderationResponse, preventEmailDelivery }
46 52
47 return this.authHttp.post(url, body) 53 return this.authHttp.post(url, body)
48 .pipe(catchError(res => this.restExtractor.handleError(res))) 54 .pipe(catchError(res => this.restExtractor.handleError(res)))
49 } 55 }
50 56
51 rejectRegistration (registration: UserRegistration, moderationResponse: string) { 57 rejectRegistration (options: {
58 registration: UserRegistration
59 moderationResponse: string
60 preventEmailDelivery: boolean
61 }) {
62 const { registration, moderationResponse, preventEmailDelivery } = options
63
52 const url = AdminRegistrationService.BASE_REGISTRATION_URL + '/' + registration.id + '/reject' 64 const url = AdminRegistrationService.BASE_REGISTRATION_URL + '/' + registration.id + '/reject'
53 const body = { moderationResponse } 65 const body: UserRegistrationUpdateState = { moderationResponse, preventEmailDelivery }
54 66
55 return this.authHttp.post(url, body) 67 return this.authHttp.post(url, body)
56 .pipe(catchError(res => this.restExtractor.handleError(res))) 68 .pipe(catchError(res => this.restExtractor.handleError(res)))
diff --git a/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.html b/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.html
index 7a33bb94b..8e46b0cf9 100644
--- a/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.html
+++ b/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.html
@@ -12,7 +12,7 @@
12 <div class="modal-body mb-3"> 12 <div class="modal-body mb-3">
13 13
14 <div i18n *ngIf="!registration.emailVerified" class="alert alert-warning"> 14 <div i18n *ngIf="!registration.emailVerified" class="alert alert-warning">
15 Registration email has not been verified. 15 Registration email has not been verified. Email delivery has been disabled by default.
16 </div> 16 </div>
17 17
18 <div class="description"> 18 <div class="description">
@@ -21,7 +21,7 @@
21 <strong>Accepting</strong>&nbsp;<em>{{ registration.username }}</em> registration will create the account and channel. 21 <strong>Accepting</strong>&nbsp;<em>{{ registration.username }}</em> registration will create the account and channel.
22 </p> 22 </p>
23 23
24 <p *ngIf="isEmailEnabled()" i18n> 24 <p *ngIf="isEmailEnabled()" i18n [ngClass]="{ 'text-decoration-line-through': isPreventEmailDeliveryChecked() }">
25 An email will be sent to <em>{{ registration.email }}</em> explaining its account has been created with the moderation response you'll write below. 25 An email will be sent to <em>{{ registration.email }}</em> explaining its account has been created with the moderation response you'll write below.
26 </p> 26 </p>
27 27
@@ -31,7 +31,7 @@
31 </ng-container> 31 </ng-container>
32 32
33 <ng-container *ngIf="isReject()"> 33 <ng-container *ngIf="isReject()">
34 <p i18n> 34 <p i18n [ngClass]="{ 'text-decoration-line-through': isPreventEmailDeliveryChecked() }">
35 An email will be sent to <em>{{ registration.email }}</em> explaining its registration request has been <strong>rejected</strong> with the moderation response you'll write below. 35 An email will be sent to <em>{{ registration.email }}</em> explaining its registration request has been <strong>rejected</strong> with the moderation response you'll write below.
36 </p> 36 </p>
37 37
@@ -53,6 +53,13 @@
53 {{ formErrors.moderationResponse }} 53 {{ formErrors.moderationResponse }}
54 </div> 54 </div>
55 </div> 55 </div>
56
57 <div class="form-group">
58 <my-peertube-checkbox
59 inputName="preventEmailDelivery" formControlName="preventEmailDelivery" [disabled]="!isEmailEnabled()"
60 i18n-labelText labelText="Prevent email from being sent to the user"
61 ></my-peertube-checkbox>
62 </div>
56 </div> 63 </div>
57 64
58 <div class="modal-footer inputs"> 65 <div class="modal-footer inputs">
diff --git a/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts b/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts
index fbe8deb41..3a7e5dea1 100644
--- a/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts
+++ b/client/src/app/+admin/moderation/registration-list/process-registration-modal.component.ts
@@ -34,7 +34,8 @@ export class ProcessRegistrationModalComponent extends FormReactive implements O
34 34
35 ngOnInit () { 35 ngOnInit () {
36 this.buildForm({ 36 this.buildForm({
37 moderationResponse: REGISTRATION_MODERATION_RESPONSE_VALIDATOR 37 moderationResponse: REGISTRATION_MODERATION_RESPONSE_VALIDATOR,
38 preventEmailDelivery: null
38 }) 39 })
39 } 40 }
40 41
@@ -50,6 +51,10 @@ export class ProcessRegistrationModalComponent extends FormReactive implements O
50 this.processMode = mode 51 this.processMode = mode
51 this.registration = registration 52 this.registration = registration
52 53
54 this.form.patchValue({
55 preventEmailDelivery: !this.isEmailEnabled() || registration.emailVerified !== true
56 })
57
53 this.openedModal = this.modalService.open(this.modal, { centered: true }) 58 this.openedModal = this.modalService.open(this.modal, { centered: true })
54 } 59 }
55 60
@@ -77,31 +82,41 @@ export class ProcessRegistrationModalComponent extends FormReactive implements O
77 return this.server.getHTMLConfig().email.enabled 82 return this.server.getHTMLConfig().email.enabled
78 } 83 }
79 84
80 private acceptRegistration () { 85 isPreventEmailDeliveryChecked () {
81 this.registrationService.acceptRegistration(this.registration, this.form.value.moderationResponse) 86 return this.form.value.preventEmailDelivery
82 .subscribe({ 87 }
83 next: () => {
84 this.notifier.success($localize`${this.registration.username} account created`)
85
86 this.registrationProcessed.emit()
87 this.hide()
88 },
89 88
90 error: err => this.notifier.error(err.message) 89 private acceptRegistration () {
91 }) 90 this.registrationService.acceptRegistration({
91 registration: this.registration,
92 moderationResponse: this.form.value.moderationResponse,
93 preventEmailDelivery: this.form.value.preventEmailDelivery
94 }).subscribe({
95 next: () => {
96 this.notifier.success($localize`${this.registration.username} account created`)
97
98 this.registrationProcessed.emit()
99 this.hide()
100 },
101
102 error: err => this.notifier.error(err.message)
103 })
92 } 104 }
93 105
94 private rejectRegistration () { 106 private rejectRegistration () {
95 this.registrationService.rejectRegistration(this.registration, this.form.value.moderationResponse) 107 this.registrationService.rejectRegistration({
96 .subscribe({ 108 registration: this.registration,
97 next: () => { 109 moderationResponse: this.form.value.moderationResponse,
98 this.notifier.success($localize`${this.registration.username} registration rejected`) 110 preventEmailDelivery: this.form.value.preventEmailDelivery
99 111 }).subscribe({
100 this.registrationProcessed.emit() 112 next: () => {
101 this.hide() 113 this.notifier.success($localize`${this.registration.username} registration rejected`)
102 }, 114
103 115 this.registrationProcessed.emit()
104 error: err => this.notifier.error(err.message) 116 this.hide()
105 }) 117 },
118
119 error: err => this.notifier.error(err.message)
120 })
106 } 121 }
107} 122}
diff --git a/client/src/app/shared/form-validators/form-validator.model.ts b/client/src/app/shared/form-validators/form-validator.model.ts
index 31c253b9b..1e4bba86b 100644
--- a/client/src/app/shared/form-validators/form-validator.model.ts
+++ b/client/src/app/shared/form-validators/form-validator.model.ts
@@ -12,5 +12,5 @@ export type BuildFormArgument = {
12} 12}
13 13
14export type BuildFormDefaultValues = { 14export type BuildFormDefaultValues = {
15 [ name: string ]: number | string | string[] | BuildFormDefaultValues 15 [ name: string ]: boolean | number | string | string[] | BuildFormDefaultValues
16} 16}