]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-moderation/user-moderation-dropdown.component.ts
Add ability to mute user when banning them
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-moderation / user-moderation-dropdown.component.ts
index 1c5240db45aa741d6efee9f286037c4f7cc61b82..0d19565efb6db6096c9b67d79faf75bea088aa9d 100644 (file)
@@ -1,7 +1,8 @@
 import { Component, EventEmitter, Input, OnChanges, OnInit, Output, ViewChild } from '@angular/core'
-import { AuthService, ConfirmService, Notifier, ServerService, UserService } from '@app/core'
+import { AuthService, ConfirmService, Notifier, ServerService } from '@app/core'
 import { Account, DropdownAction } from '@app/shared/shared-main'
 import { BulkRemoveCommentsOfBody, User, UserRight } from '@shared/models'
+import { UserAdminService } from '../shared-users'
 import { BlocklistService } from './blocklist.service'
 import { BulkService } from './bulk.service'
 import { UserBanModalComponent } from './user-ban-modal.component'
@@ -35,7 +36,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
     private notifier: Notifier,
     private confirmService: ConfirmService,
     private serverService: ServerService,
-    private userService: UserService,
+    private userAdminService: UserAdminService,
     private blocklistService: BlocklistService,
     private bulkService: BulkService
   ) { }
@@ -66,7 +67,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
     const res = await this.confirmService.confirm($localize`Do you really want to unban ${user.username}?`, $localize`Unban`)
     if (res === false) return
 
-    this.userService.unbanUsers(user)
+    this.userAdminService.unbanUsers(user)
         .subscribe({
           next: () => {
             this.notifier.success($localize`User ${user.username} unbanned.`)
@@ -83,11 +84,11 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
       return
     }
 
-    const message = $localize`If you remove this user, you will not be able to create another with the same username!`
-    const res = await this.confirmService.confirm(message, $localize`Delete`)
+    const message = $localize`If you remove user ${user.username}, you won't be able to create another with the same username!`
+    const res = await this.confirmService.confirm(message, $localize`Delete ${user.username}`)
     if (res === false) return
 
-    this.userService.removeUser(user)
+    this.userAdminService.removeUser(user)
       .subscribe({
         next: () => {
           this.notifier.success($localize`User ${user.username} deleted.`)
@@ -99,7 +100,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
   }
 
   setEmailAsVerified (user: User) {
-    this.userService.updateUser(user.id, { emailVerified: true })
+    this.userAdminService.updateUser(user.id, { emailVerified: true })
       .subscribe({
         next: () => {
           this.notifier.success($localize`User ${user.username} email set as verified`)
@@ -270,7 +271,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
 
     const myAccountActions: DropdownAction<{ user: User, account: Account }>[] = [
       {
-        label: $localize`Personal moderation`,
+        label: $localize`My account moderation`,
         class: [ 'red' ],
         isHeader: true
       },
@@ -289,13 +290,13 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
       {
         label: $localize`Mute the instance`,
         description: $localize`Hide any content from that instance for you.`,
-        isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === false,
+        isDisplayed: ({ account }) => !account.userId && account.mutedServerByUser === false,
         handler: ({ account }) => this.blockServerByUser(account.host)
       },
       {
         label: $localize`Unmute the instance`,
         description: $localize`Show back content from that instance for you.`,
-        isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === true,
+        isDisplayed: ({ account }) => !account.userId && account.mutedServerByUser === true,
         handler: ({ account }) => this.unblockServerByUser(account.host)
       },
       {