aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts')
-rw-r--r--client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts77
1 files changed, 35 insertions, 42 deletions
diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
index c7dc5f4d2..cc933db0d 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
+++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
@@ -1,16 +1,15 @@
1import * as debug from 'debug' 1import * as debug from 'debug'
2import truncate from 'lodash-es/truncate' 2import truncate from 'lodash-es/truncate'
3import { SortMeta } from 'primeng/api' 3import { SortMeta } from 'primeng/api'
4import { buildVideoOrPlaylistEmbed, buildVideoLink } from 'src/assets/player/utils' 4import { buildVideoLink, buildVideoOrPlaylistEmbed } from 'src/assets/player/utils'
5import { environment } from 'src/environments/environment' 5import { environment } from 'src/environments/environment'
6import { AfterViewInit, Component, OnInit, ViewChild, Input } from '@angular/core' 6import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core'
7import { DomSanitizer } from '@angular/platform-browser' 7import { DomSanitizer } from '@angular/platform-browser'
8import { ActivatedRoute, Params, Router } from '@angular/router' 8import { ActivatedRoute, Params, Router } from '@angular/router'
9import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core' 9import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core'
10import { Account, Actor, DropdownAction, Video, VideoService } from '@app/shared/shared-main' 10import { Account, Actor, DropdownAction, Video, VideoService } from '@app/shared/shared-main'
11import { AbuseService, BlocklistService, VideoBlockService } from '@app/shared/shared-moderation' 11import { AbuseService, BlocklistService, VideoBlockService } from '@app/shared/shared-moderation'
12import { VideoCommentService } from '@app/shared/shared-video-comment' 12import { VideoCommentService } from '@app/shared/shared-video-comment'
13import { I18n } from '@ngx-translate/i18n-polyfill'
14import { AbuseState, AdminAbuse } from '@shared/models' 13import { AbuseState, AdminAbuse } from '@shared/models'
15import { AbuseMessageModalComponent } from './abuse-message-modal.component' 14import { AbuseMessageModalComponent } from './abuse-message-modal.component'
16import { ModerationCommentModalComponent } from './moderation-comment-modal.component' 15import { ModerationCommentModalComponent } from './moderation-comment-modal.component'
@@ -45,7 +44,6 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
45 private videoService: VideoService, 44 private videoService: VideoService,
46 private videoBlocklistService: VideoBlockService, 45 private videoBlocklistService: VideoBlockService,
47 private confirmService: ConfirmService, 46 private confirmService: ConfirmService,
48 private i18n: I18n,
49 private markdownRenderer: MarkdownService, 47 private markdownRenderer: MarkdownService,
50 private sanitizer: DomSanitizer, 48 private sanitizer: DomSanitizer,
51 private route: ActivatedRoute, 49 private route: ActivatedRoute,
@@ -157,12 +155,12 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
157 } 155 }
158 156
159 async removeAbuse (abuse: AdminAbuse) { 157 async removeAbuse (abuse: AdminAbuse) {
160 const res = await this.confirmService.confirm(this.i18n('Do you really want to delete this abuse report?'), this.i18n('Delete')) 158 const res = await this.confirmService.confirm($localize`Do you really want to delete this abuse report?`, $localize`Delete`)
161 if (res === false) return 159 if (res === false) return
162 160
163 this.abuseService.removeAbuse(abuse).subscribe( 161 this.abuseService.removeAbuse(abuse).subscribe(
164 () => { 162 () => {
165 this.notifier.success(this.i18n('Abuse deleted.')) 163 this.notifier.success($localize`Abuse deleted.`)
166 this.loadData() 164 this.loadData()
167 }, 165 },
168 166
@@ -238,7 +236,7 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
238 236
239 if (abuse.comment) { 237 if (abuse.comment) {
240 if (abuse.comment.deleted) { 238 if (abuse.comment.deleted) {
241 abuse.truncatedCommentHtml = abuse.commentHtml = this.i18n('Deleted comment') 239 abuse.truncatedCommentHtml = abuse.commentHtml = $localize`Deleted comment`
242 } else { 240 } else {
243 const truncated = truncate(abuse.comment.text, { length: 100 }) 241 const truncated = truncate(abuse.comment.text, { length: 100 })
244 abuse.truncatedCommentHtml = await this.markdownRenderer.textMarkdownToHTML(truncated, true) 242 abuse.truncatedCommentHtml = await this.markdownRenderer.textMarkdownToHTML(truncated, true)
@@ -267,38 +265,38 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
267 private buildInternalActions (): DropdownAction<ProcessedAbuse>[] { 265 private buildInternalActions (): DropdownAction<ProcessedAbuse>[] {
268 return [ 266 return [
269 { 267 {
270 label: this.i18n('Internal actions'), 268 label: $localize`Internal actions`,
271 isHeader: true 269 isHeader: true
272 }, 270 },
273 { 271 {
274 label: this.isAdminView() 272 label: this.isAdminView()
275 ? this.i18n('Messages with reporter') 273 ? $localize`Messages with reporter`
276 : this.i18n('Messages with moderators'), 274 : $localize`Messages with moderators`,
277 handler: abuse => this.openAbuseMessagesModal(abuse), 275 handler: abuse => this.openAbuseMessagesModal(abuse),
278 isDisplayed: abuse => this.isLocalAbuse(abuse) 276 isDisplayed: abuse => this.isLocalAbuse(abuse)
279 }, 277 },
280 { 278 {
281 label: this.i18n('Update internal note'), 279 label: $localize`Update internal note`,
282 handler: abuse => this.openModerationCommentModal(abuse), 280 handler: abuse => this.openModerationCommentModal(abuse),
283 isDisplayed: abuse => this.isAdminView() && !!abuse.moderationComment 281 isDisplayed: abuse => this.isAdminView() && !!abuse.moderationComment
284 }, 282 },
285 { 283 {
286 label: this.i18n('Mark as accepted'), 284 label: $localize`Mark as accepted`,
287 handler: abuse => this.updateAbuseState(abuse, AbuseState.ACCEPTED), 285 handler: abuse => this.updateAbuseState(abuse, AbuseState.ACCEPTED),
288 isDisplayed: abuse => this.isAdminView() && !this.isAbuseAccepted(abuse) 286 isDisplayed: abuse => this.isAdminView() && !this.isAbuseAccepted(abuse)
289 }, 287 },
290 { 288 {
291 label: this.i18n('Mark as rejected'), 289 label: $localize`Mark as rejected`,
292 handler: abuse => this.updateAbuseState(abuse, AbuseState.REJECTED), 290 handler: abuse => this.updateAbuseState(abuse, AbuseState.REJECTED),
293 isDisplayed: abuse => this.isAdminView() && !this.isAbuseRejected(abuse) 291 isDisplayed: abuse => this.isAdminView() && !this.isAbuseRejected(abuse)
294 }, 292 },
295 { 293 {
296 label: this.i18n('Add internal note'), 294 label: $localize`Add internal note`,
297 handler: abuse => this.openModerationCommentModal(abuse), 295 handler: abuse => this.openModerationCommentModal(abuse),
298 isDisplayed: abuse => this.isAdminView() && !abuse.moderationComment 296 isDisplayed: abuse => this.isAdminView() && !abuse.moderationComment
299 }, 297 },
300 { 298 {
301 label: this.i18n('Delete report'), 299 label: $localize`Delete report`,
302 handler: abuse => this.isAdminView() && this.removeAbuse(abuse) 300 handler: abuse => this.isAdminView() && this.removeAbuse(abuse)
303 } 301 }
304 ] 302 ]
@@ -309,19 +307,19 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
309 307
310 return [ 308 return [
311 { 309 {
312 label: this.i18n('Actions for the flagged account'), 310 label: $localize`Actions for the flagged account`,
313 isHeader: true, 311 isHeader: true,
314 isDisplayed: abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video 312 isDisplayed: abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video
315 }, 313 },
316 314
317 { 315 {
318 label: this.i18n('Mute account'), 316 label: $localize`Mute account`,
319 isDisplayed: abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video, 317 isDisplayed: abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video,
320 handler: abuse => this.muteAccountHelper(abuse.flaggedAccount) 318 handler: abuse => this.muteAccountHelper(abuse.flaggedAccount)
321 }, 319 },
322 320
323 { 321 {
324 label: this.i18n('Mute server account'), 322 label: $localize`Mute server account`,
325 isDisplayed: abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video, 323 isDisplayed: abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video,
326 handler: abuse => this.muteServerHelper(abuse.flaggedAccount.host) 324 handler: abuse => this.muteServerHelper(abuse.flaggedAccount.host)
327 } 325 }
@@ -333,19 +331,19 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
333 331
334 return [ 332 return [
335 { 333 {
336 label: this.i18n('Actions for the reporter'), 334 label: $localize`Actions for the reporter`,
337 isHeader: true, 335 isHeader: true,
338 isDisplayed: abuse => !!abuse.reporterAccount 336 isDisplayed: abuse => !!abuse.reporterAccount
339 }, 337 },
340 338
341 { 339 {
342 label: this.i18n('Mute reporter'), 340 label: $localize`Mute reporter`,
343 isDisplayed: abuse => !!abuse.reporterAccount, 341 isDisplayed: abuse => !!abuse.reporterAccount,
344 handler: abuse => this.muteAccountHelper(abuse.reporterAccount) 342 handler: abuse => this.muteAccountHelper(abuse.reporterAccount)
345 }, 343 },
346 344
347 { 345 {
348 label: this.i18n('Mute server'), 346 label: $localize`Mute server`,
349 isDisplayed: abuse => abuse.reporterAccount && !abuse.reporterAccount.userId, 347 isDisplayed: abuse => abuse.reporterAccount && !abuse.reporterAccount.userId,
350 handler: abuse => this.muteServerHelper(abuse.reporterAccount.host) 348 handler: abuse => this.muteServerHelper(abuse.reporterAccount.host)
351 } 349 }
@@ -357,18 +355,18 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
357 355
358 return [ 356 return [
359 { 357 {
360 label: this.i18n('Actions for the video'), 358 label: $localize`Actions for the video`,
361 isHeader: true, 359 isHeader: true,
362 isDisplayed: abuse => abuse.video && !abuse.video.deleted 360 isDisplayed: abuse => abuse.video && !abuse.video.deleted
363 }, 361 },
364 { 362 {
365 label: this.i18n('Block video'), 363 label: $localize`Block video`,
366 isDisplayed: abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted, 364 isDisplayed: abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted,
367 handler: abuse => { 365 handler: abuse => {
368 this.videoBlocklistService.blockVideo(abuse.video.id, undefined, true) 366 this.videoBlocklistService.blockVideo(abuse.video.id, undefined, true)
369 .subscribe( 367 .subscribe(
370 () => { 368 () => {
371 this.notifier.success(this.i18n('Video blocked.')) 369 this.notifier.success($localize`Video blocked.`)
372 370
373 this.updateAbuseState(abuse, AbuseState.ACCEPTED) 371 this.updateAbuseState(abuse, AbuseState.ACCEPTED)
374 }, 372 },
@@ -378,13 +376,13 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
378 } 376 }
379 }, 377 },
380 { 378 {
381 label: this.i18n('Unblock video'), 379 label: $localize`Unblock video`,
382 isDisplayed: abuse => abuse.video && !abuse.video.deleted && abuse.video.blacklisted, 380 isDisplayed: abuse => abuse.video && !abuse.video.deleted && abuse.video.blacklisted,
383 handler: abuse => { 381 handler: abuse => {
384 this.videoBlocklistService.unblockVideo(abuse.video.id) 382 this.videoBlocklistService.unblockVideo(abuse.video.id)
385 .subscribe( 383 .subscribe(
386 () => { 384 () => {
387 this.notifier.success(this.i18n('Video unblocked.')) 385 this.notifier.success($localize`Video unblocked.`)
388 386
389 this.updateAbuseState(abuse, AbuseState.ACCEPTED) 387 this.updateAbuseState(abuse, AbuseState.ACCEPTED)
390 }, 388 },
@@ -394,19 +392,19 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
394 } 392 }
395 }, 393 },
396 { 394 {
397 label: this.i18n('Delete video'), 395 label: $localize`Delete video`,
398 isDisplayed: abuse => abuse.video && !abuse.video.deleted, 396 isDisplayed: abuse => abuse.video && !abuse.video.deleted,
399 handler: async abuse => { 397 handler: async abuse => {
400 const res = await this.confirmService.confirm( 398 const res = await this.confirmService.confirm(
401 this.i18n('Do you really want to delete this video?'), 399 $localize`Do you really want to delete this video?`,
402 this.i18n('Delete') 400 $localize`Delete`
403 ) 401 )
404 if (res === false) return 402 if (res === false) return
405 403
406 this.videoService.removeVideo(abuse.video.id) 404 this.videoService.removeVideo(abuse.video.id)
407 .subscribe( 405 .subscribe(
408 () => { 406 () => {
409 this.notifier.success(this.i18n('Video deleted.')) 407 this.notifier.success($localize`Video deleted.`)
410 408
411 this.updateAbuseState(abuse, AbuseState.ACCEPTED) 409 this.updateAbuseState(abuse, AbuseState.ACCEPTED)
412 }, 410 },
@@ -423,25 +421,25 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
423 421
424 return [ 422 return [
425 { 423 {
426 label: this.i18n('Actions for the comment'), 424 label: $localize`Actions for the comment`,
427 isHeader: true, 425 isHeader: true,
428 isDisplayed: abuse => abuse.comment && !abuse.comment.deleted 426 isDisplayed: abuse => abuse.comment && !abuse.comment.deleted
429 }, 427 },
430 428
431 { 429 {
432 label: this.i18n('Delete comment'), 430 label: $localize`Delete comment`,
433 isDisplayed: abuse => abuse.comment && !abuse.comment.deleted, 431 isDisplayed: abuse => abuse.comment && !abuse.comment.deleted,
434 handler: async abuse => { 432 handler: async abuse => {
435 const res = await this.confirmService.confirm( 433 const res = await this.confirmService.confirm(
436 this.i18n('Do you really want to delete this comment?'), 434 $localize`Do you really want to delete this comment?`,
437 this.i18n('Delete') 435 $localize`Delete`
438 ) 436 )
439 if (res === false) return 437 if (res === false) return
440 438
441 this.commentService.deleteVideoComment(abuse.comment.video.id, abuse.comment.id) 439 this.commentService.deleteVideoComment(abuse.comment.video.id, abuse.comment.id)
442 .subscribe( 440 .subscribe(
443 () => { 441 () => {
444 this.notifier.success(this.i18n('Comment deleted.')) 442 this.notifier.success($localize`Comment deleted.`)
445 443
446 this.updateAbuseState(abuse, AbuseState.ACCEPTED) 444 this.updateAbuseState(abuse, AbuseState.ACCEPTED)
447 }, 445 },
@@ -457,10 +455,7 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
457 this.blocklistService.blockAccountByInstance(account) 455 this.blocklistService.blockAccountByInstance(account)
458 .subscribe( 456 .subscribe(
459 () => { 457 () => {
460 this.notifier.success( 458 this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`)
461 this.i18n('Account {{nameWithHost}} muted by the instance.', { nameWithHost: account.nameWithHost })
462 )
463
464 account.mutedByInstance = true 459 account.mutedByInstance = true
465 }, 460 },
466 461
@@ -472,9 +467,7 @@ export class AbuseListTableComponent extends RestTable implements OnInit, AfterV
472 this.blocklistService.blockServerByInstance(host) 467 this.blocklistService.blockServerByInstance(host)
473 .subscribe( 468 .subscribe(
474 () => { 469 () => {
475 this.notifier.success( 470 this.notifier.success($localize`Server ${host} muted by the instance.`)
476 this.i18n('Server {{host}} muted by the instance.', { host: host })
477 )
478 }, 471 },
479 472
480 err => this.notifier.error(err.message) 473 err => this.notifier.error(err.message)