diff options
author | Poslovitch <poslovitch@bentobox.world> | 2021-12-21 12:23:36 +0000 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2022-02-28 11:36:31 +0100 |
commit | 5a8de57d574045c5f819b8c81fb0530a9e9a699f (patch) | |
tree | a91bf1ab21b33d092864c2e2f9662d3e5f69c4c1 /client | |
parent | 0ff01f837b9a291fc6e93a736f7574b618ad0253 (diff) | |
download | PeerTube-5a8de57d574045c5f819b8c81fb0530a9e9a699f.tar.gz PeerTube-5a8de57d574045c5f819b8c81fb0530a9e9a699f.tar.zst PeerTube-5a8de57d574045c5f819b8c81fb0530a9e9a699f.zip |
Add ability to mute user when banning them
Implements https://github.com/Chocobozzz/PeerTube/issues/1803
Diffstat (limited to 'client')
-rw-r--r-- | client/src/app/shared/shared-moderation/user-ban-modal.component.html | 7 | ||||
-rw-r--r-- | client/src/app/shared/shared-moderation/user-ban-modal.component.ts | 26 |
2 files changed, 31 insertions, 2 deletions
diff --git a/client/src/app/shared/shared-moderation/user-ban-modal.component.html b/client/src/app/shared/shared-moderation/user-ban-modal.component.html index b41ae230d..6c83cc9cc 100644 --- a/client/src/app/shared/shared-moderation/user-ban-modal.component.html +++ b/client/src/app/shared/shared-moderation/user-ban-modal.component.html | |||
@@ -21,6 +21,13 @@ | |||
21 | A banned user will no longer be able to login. | 21 | A banned user will no longer be able to login. |
22 | </div> | 22 | </div> |
23 | 23 | ||
24 | <div class="form-group"> | ||
25 | <my-peertube-checkbox | ||
26 | inputName="banMute" formControlName="mute" | ||
27 | i18n-labelText labelText="Mute this account" | ||
28 | ></my-peertube-checkbox> | ||
29 | </div> | ||
30 | |||
24 | <div class="form-group inputs"> | 31 | <div class="form-group inputs"> |
25 | <input | 32 | <input |
26 | type="button" role="button" i18n-value value="Cancel" class="peertube-button grey-button" | 33 | type="button" role="button" i18n-value value="Cancel" class="peertube-button grey-button" |
diff --git a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts index 17cad18ec..b3f03990f 100644 --- a/client/src/app/shared/shared-moderation/user-ban-modal.component.ts +++ b/client/src/app/shared/shared-moderation/user-ban-modal.component.ts | |||
@@ -5,7 +5,9 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | |||
5 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' | 5 | import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref' |
6 | import { User } from '@shared/models' | 6 | import { User } from '@shared/models' |
7 | import { USER_BAN_REASON_VALIDATOR } from '../form-validators/user-validators' | 7 | import { USER_BAN_REASON_VALIDATOR } from '../form-validators/user-validators' |
8 | import { Account } from '../shared-main' | ||
8 | import { UserAdminService } from '../shared-users' | 9 | import { UserAdminService } from '../shared-users' |
10 | import { BlocklistService } from './blocklist.service' | ||
9 | 11 | ||
10 | @Component({ | 12 | @Component({ |
11 | selector: 'my-user-ban-modal', | 13 | selector: 'my-user-ban-modal', |
@@ -24,14 +26,16 @@ export class UserBanModalComponent extends FormReactive implements OnInit { | |||
24 | protected formValidatorService: FormValidatorService, | 26 | protected formValidatorService: FormValidatorService, |
25 | private modalService: NgbModal, | 27 | private modalService: NgbModal, |
26 | private notifier: Notifier, | 28 | private notifier: Notifier, |
27 | private userAdminService: UserAdminService | 29 | private userAdminService: UserAdminService, |
30 | private blocklistService: BlocklistService | ||
28 | ) { | 31 | ) { |
29 | super() | 32 | super() |
30 | } | 33 | } |
31 | 34 | ||
32 | ngOnInit () { | 35 | ngOnInit () { |
33 | this.buildForm({ | 36 | this.buildForm({ |
34 | reason: USER_BAN_REASON_VALIDATOR | 37 | reason: USER_BAN_REASON_VALIDATOR, |
38 | mute: null | ||
35 | }) | 39 | }) |
36 | } | 40 | } |
37 | 41 | ||
@@ -50,6 +54,7 @@ export class UserBanModalComponent extends FormReactive implements OnInit { | |||
50 | 54 | ||
51 | banUser () { | 55 | banUser () { |
52 | const reason = this.form.value['reason'] || undefined | 56 | const reason = this.form.value['reason'] || undefined |
57 | const mute = this.form.value['mute'] | ||
53 | 58 | ||
54 | this.userAdminService.banUsers(this.usersToBan, reason) | 59 | this.userAdminService.banUsers(this.usersToBan, reason) |
55 | .subscribe({ | 60 | .subscribe({ |
@@ -61,6 +66,23 @@ export class UserBanModalComponent extends FormReactive implements OnInit { | |||
61 | this.notifier.success(message) | 66 | this.notifier.success(message) |
62 | 67 | ||
63 | this.userBanned.emit(this.usersToBan) | 68 | this.userBanned.emit(this.usersToBan) |
69 | |||
70 | if (mute) { | ||
71 | const users = Array.isArray(this.usersToBan) ? this.usersToBan : [ this.usersToBan ] | ||
72 | users.forEach(user => { | ||
73 | const account = new Account(user.account) | ||
74 | this.blocklistService.blockAccountByInstance(account) | ||
75 | .subscribe({ | ||
76 | next: () => { | ||
77 | this.notifier.success($localize`Account ${user.username} muted by the instance.`) | ||
78 | account.mutedByInstance = true | ||
79 | }, | ||
80 | |||
81 | error: err => this.notifier.error(err.message) | ||
82 | }) | ||
83 | }) | ||
84 | } | ||
85 | |||
64 | this.hide() | 86 | this.hide() |
65 | }, | 87 | }, |
66 | 88 | ||