diff options
Diffstat (limited to 'client/src/app/shared/moderation')
-rw-r--r-- | client/src/app/shared/moderation/user-moderation-dropdown.component.ts | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts index f8ad7ce13..82f39050e 100644 --- a/client/src/app/shared/moderation/user-moderation-dropdown.component.ts +++ b/client/src/app/shared/moderation/user-moderation-dropdown.component.ts | |||
@@ -7,7 +7,8 @@ import { AuthService, ConfirmService, Notifier, ServerService } from '@app/core' | |||
7 | import { User, UserRight } from '../../../../../shared/models/users' | 7 | import { User, UserRight } from '../../../../../shared/models/users' |
8 | import { Account } from '@app/shared/account/account.model' | 8 | import { Account } from '@app/shared/account/account.model' |
9 | import { BlocklistService } from '@app/shared/blocklist' | 9 | import { BlocklistService } from '@app/shared/blocklist' |
10 | import { ServerConfig } from '@shared/models' | 10 | import { ServerConfig, BulkRemoveCommentsOfBody } from '@shared/models' |
11 | import { BulkService } from '../bulk/bulk.service' | ||
11 | 12 | ||
12 | @Component({ | 13 | @Component({ |
13 | selector: 'my-user-moderation-dropdown', | 14 | selector: 'my-user-moderation-dropdown', |
@@ -38,6 +39,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
38 | private serverService: ServerService, | 39 | private serverService: ServerService, |
39 | private userService: UserService, | 40 | private userService: UserService, |
40 | private blocklistService: BlocklistService, | 41 | private blocklistService: BlocklistService, |
42 | private bulkService: BulkService, | ||
41 | private i18n: I18n | 43 | private i18n: I18n |
42 | ) { } | 44 | ) { } |
43 | 45 | ||
@@ -229,6 +231,21 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
229 | ) | 231 | ) |
230 | } | 232 | } |
231 | 233 | ||
234 | async bulkRemoveCommentsOf (body: BulkRemoveCommentsOfBody) { | ||
235 | const message = this.i18n('Are you sure you want to remove all the comments of this account?') | ||
236 | const res = await this.confirmService.confirm(message, this.i18n('Delete account comments')) | ||
237 | if (res === false) return | ||
238 | |||
239 | this.bulkService.removeCommentsOf(body) | ||
240 | .subscribe( | ||
241 | () => { | ||
242 | this.notifier.success(this.i18n('Will remove comments of this account (may take several minutes).')) | ||
243 | }, | ||
244 | |||
245 | err => this.notifier.error(err.message) | ||
246 | ) | ||
247 | } | ||
248 | |||
232 | getRouterUserEditLink (user: User) { | 249 | getRouterUserEditLink (user: User) { |
233 | return [ '/admin', 'users', 'update', user.id ] | 250 | return [ '/admin', 'users', 'update', user.id ] |
234 | } | 251 | } |
@@ -300,12 +317,17 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
300 | description: this.i18n('Show back content from that instance for you.'), | 317 | description: this.i18n('Show back content from that instance for you.'), |
301 | isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === true, | 318 | isDisplayed: ({ account }) => !account.userId && account.mutedServerByInstance === true, |
302 | handler: ({ account }) => this.unblockServerByUser(account.host) | 319 | handler: ({ account }) => this.unblockServerByUser(account.host) |
320 | }, | ||
321 | { | ||
322 | label: this.i18n('Remove comments from your videos'), | ||
323 | description: this.i18n('Remove comments of this account from your videos.'), | ||
324 | handler: ({ account }) => this.bulkRemoveCommentsOf({ accountName: account.nameWithHost, scope: 'my-videos' }) | ||
303 | } | 325 | } |
304 | ]) | 326 | ]) |
305 | 327 | ||
306 | let instanceActions: DropdownAction<{ user: User, account: Account }>[] = [] | 328 | let instanceActions: DropdownAction<{ user: User, account: Account }>[] = [] |
307 | 329 | ||
308 | // Instance actions | 330 | // Instance actions on account blocklists |
309 | if (authUser.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)) { | 331 | if (authUser.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)) { |
310 | instanceActions = instanceActions.concat([ | 332 | instanceActions = instanceActions.concat([ |
311 | { | 333 | { |
@@ -323,7 +345,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
323 | ]) | 345 | ]) |
324 | } | 346 | } |
325 | 347 | ||
326 | // Instance actions | 348 | // Instance actions on server blocklists |
327 | if (authUser.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)) { | 349 | if (authUser.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)) { |
328 | instanceActions = instanceActions.concat([ | 350 | instanceActions = instanceActions.concat([ |
329 | { | 351 | { |
@@ -341,6 +363,16 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges { | |||
341 | ]) | 363 | ]) |
342 | } | 364 | } |
343 | 365 | ||
366 | if (authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT)) { | ||
367 | instanceActions = instanceActions.concat([ | ||
368 | { | ||
369 | label: this.i18n('Remove comments from your instance'), | ||
370 | description: this.i18n('Remove comments of this account from your instance.'), | ||
371 | handler: ({ account }) => this.bulkRemoveCommentsOf({ accountName: account.nameWithHost, scope: 'instance' }) | ||
372 | } | ||
373 | ]) | ||
374 | } | ||
375 | |||
344 | if (instanceActions.length !== 0) { | 376 | if (instanceActions.length !== 0) { |
345 | this.userActions.push(instanceActions) | 377 | this.userActions.push(instanceActions) |
346 | } | 378 | } |