diff options
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.ts | 141 |
1 files changed, 71 insertions, 70 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 a7932ebab..e3bf9e1fb 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 | |||
@@ -145,23 +145,24 @@ export class AbuseListTableComponent extends RestTable implements OnInit { | |||
145 | const res = await this.confirmService.confirm($localize`Do you really want to delete this abuse report?`, $localize`Delete`) | 145 | const res = await this.confirmService.confirm($localize`Do you really want to delete this abuse report?`, $localize`Delete`) |
146 | if (res === false) return | 146 | if (res === false) return |
147 | 147 | ||
148 | this.abuseService.removeAbuse(abuse).subscribe( | 148 | this.abuseService.removeAbuse(abuse) |
149 | () => { | 149 | .subscribe({ |
150 | this.notifier.success($localize`Abuse deleted.`) | 150 | next: () => { |
151 | this.reloadData() | 151 | this.notifier.success($localize`Abuse deleted.`) |
152 | }, | 152 | this.reloadData() |
153 | }, | ||
153 | 154 | ||
154 | err => this.notifier.error(err.message) | 155 | error: err => this.notifier.error(err.message) |
155 | ) | 156 | }) |
156 | } | 157 | } |
157 | 158 | ||
158 | updateAbuseState (abuse: AdminAbuse, state: AbuseState) { | 159 | updateAbuseState (abuse: AdminAbuse, state: AbuseState) { |
159 | this.abuseService.updateAbuse(abuse, { state }) | 160 | this.abuseService.updateAbuse(abuse, { state }) |
160 | .subscribe( | 161 | .subscribe({ |
161 | () => this.reloadData(), | 162 | next: () => this.reloadData(), |
162 | 163 | ||
163 | err => this.notifier.error(err.message) | 164 | error: err => this.notifier.error(err.message) |
164 | ) | 165 | }) |
165 | } | 166 | } |
166 | 167 | ||
167 | onCountMessagesUpdated (event: { abuseId: number, countMessages: number }) { | 168 | onCountMessagesUpdated (event: { abuseId: number, countMessages: number }) { |
@@ -198,55 +199,55 @@ export class AbuseListTableComponent extends RestTable implements OnInit { | |||
198 | ? this.abuseService.getAdminAbuses(options) | 199 | ? this.abuseService.getAdminAbuses(options) |
199 | : this.abuseService.getUserAbuses(options) | 200 | : this.abuseService.getUserAbuses(options) |
200 | 201 | ||
201 | return observable.subscribe( | 202 | return observable.subscribe({ |
202 | async resultList => { | 203 | next: async resultList => { |
203 | this.totalRecords = resultList.total | 204 | this.totalRecords = resultList.total |
204 | 205 | ||
205 | this.abuses = [] | 206 | this.abuses = [] |
206 | 207 | ||
207 | for (const a of resultList.data) { | 208 | for (const a of resultList.data) { |
208 | const abuse = a as ProcessedAbuse | 209 | const abuse = a as ProcessedAbuse |
209 | 210 | ||
210 | abuse.reasonHtml = await this.toHtml(abuse.reason) | 211 | abuse.reasonHtml = await this.toHtml(abuse.reason) |
211 | 212 | ||
212 | if (abuse.moderationComment) { | 213 | if (abuse.moderationComment) { |
213 | abuse.moderationCommentHtml = await this.toHtml(abuse.moderationComment) | 214 | abuse.moderationCommentHtml = await this.toHtml(abuse.moderationComment) |
214 | } | 215 | } |
215 | 216 | ||
216 | if (abuse.video) { | 217 | if (abuse.video) { |
217 | abuse.embedHtml = this.sanitizer.bypassSecurityTrustHtml(this.getVideoEmbed(abuse)) | 218 | abuse.embedHtml = this.sanitizer.bypassSecurityTrustHtml(this.getVideoEmbed(abuse)) |
218 | 219 | ||
219 | if (abuse.video.channel?.ownerAccount) { | 220 | if (abuse.video.channel?.ownerAccount) { |
220 | abuse.video.channel.ownerAccount = new Account(abuse.video.channel.ownerAccount) | 221 | abuse.video.channel.ownerAccount = new Account(abuse.video.channel.ownerAccount) |
221 | } | ||
222 | } | 222 | } |
223 | } | ||
223 | 224 | ||
224 | if (abuse.comment) { | 225 | if (abuse.comment) { |
225 | if (abuse.comment.deleted) { | 226 | if (abuse.comment.deleted) { |
226 | abuse.truncatedCommentHtml = abuse.commentHtml = $localize`Deleted comment` | 227 | abuse.truncatedCommentHtml = abuse.commentHtml = $localize`Deleted comment` |
227 | } else { | 228 | } else { |
228 | const truncated = truncate(abuse.comment.text, { length: 100 }) | 229 | const truncated = truncate(abuse.comment.text, { length: 100 }) |
229 | abuse.truncatedCommentHtml = await this.markdownRenderer.textMarkdownToHTML(truncated, true) | 230 | abuse.truncatedCommentHtml = await this.markdownRenderer.textMarkdownToHTML(truncated, true) |
230 | abuse.commentHtml = await this.markdownRenderer.textMarkdownToHTML(abuse.comment.text, true) | 231 | abuse.commentHtml = await this.markdownRenderer.textMarkdownToHTML(abuse.comment.text, true) |
231 | } | ||
232 | } | 232 | } |
233 | } | ||
233 | 234 | ||
234 | if (abuse.reporterAccount) { | 235 | if (abuse.reporterAccount) { |
235 | abuse.reporterAccount = new Account(abuse.reporterAccount) | 236 | abuse.reporterAccount = new Account(abuse.reporterAccount) |
236 | } | 237 | } |
237 | 238 | ||
238 | if (abuse.flaggedAccount) { | 239 | if (abuse.flaggedAccount) { |
239 | abuse.flaggedAccount = new Account(abuse.flaggedAccount) | 240 | abuse.flaggedAccount = new Account(abuse.flaggedAccount) |
240 | } | 241 | } |
241 | 242 | ||
242 | if (abuse.updatedAt === abuse.createdAt) delete abuse.updatedAt | 243 | if (abuse.updatedAt === abuse.createdAt) delete abuse.updatedAt |
243 | 244 | ||
244 | this.abuses.push(abuse) | 245 | this.abuses.push(abuse) |
245 | } | 246 | } |
246 | }, | 247 | }, |
247 | 248 | ||
248 | err => this.notifier.error(err.message) | 249 | error: err => this.notifier.error(err.message) |
249 | ) | 250 | }) |
250 | } | 251 | } |
251 | 252 | ||
252 | private buildInternalActions (): DropdownAction<ProcessedAbuse>[] { | 253 | private buildInternalActions (): DropdownAction<ProcessedAbuse>[] { |
@@ -351,15 +352,15 @@ export class AbuseListTableComponent extends RestTable implements OnInit { | |||
351 | isDisplayed: abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted, | 352 | isDisplayed: abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted, |
352 | handler: abuse => { | 353 | handler: abuse => { |
353 | this.videoBlocklistService.blockVideo(abuse.video.id, undefined, abuse.video.channel.isLocal) | 354 | this.videoBlocklistService.blockVideo(abuse.video.id, undefined, abuse.video.channel.isLocal) |
354 | .subscribe( | 355 | .subscribe({ |
355 | () => { | 356 | next: () => { |
356 | this.notifier.success($localize`Video blocked.`) | 357 | this.notifier.success($localize`Video blocked.`) |
357 | 358 | ||
358 | this.updateAbuseState(abuse, AbuseState.ACCEPTED) | 359 | this.updateAbuseState(abuse, AbuseState.ACCEPTED) |
359 | }, | 360 | }, |
360 | 361 | ||
361 | err => this.notifier.error(err.message) | 362 | error: err => this.notifier.error(err.message) |
362 | ) | 363 | }) |
363 | } | 364 | } |
364 | }, | 365 | }, |
365 | { | 366 | { |
@@ -367,15 +368,15 @@ export class AbuseListTableComponent extends RestTable implements OnInit { | |||
367 | isDisplayed: abuse => abuse.video && !abuse.video.deleted && abuse.video.blacklisted, | 368 | isDisplayed: abuse => abuse.video && !abuse.video.deleted && abuse.video.blacklisted, |
368 | handler: abuse => { | 369 | handler: abuse => { |
369 | this.videoBlocklistService.unblockVideo(abuse.video.id) | 370 | this.videoBlocklistService.unblockVideo(abuse.video.id) |
370 | .subscribe( | 371 | .subscribe({ |
371 | () => { | 372 | next: () => { |
372 | this.notifier.success($localize`Video unblocked.`) | 373 | this.notifier.success($localize`Video unblocked.`) |
373 | 374 | ||
374 | this.updateAbuseState(abuse, AbuseState.ACCEPTED) | 375 | this.updateAbuseState(abuse, AbuseState.ACCEPTED) |
375 | }, | 376 | }, |
376 | 377 | ||
377 | err => this.notifier.error(err.message) | 378 | error: err => this.notifier.error(err.message) |
378 | ) | 379 | }) |
379 | } | 380 | } |
380 | }, | 381 | }, |
381 | { | 382 | { |
@@ -389,15 +390,15 @@ export class AbuseListTableComponent extends RestTable implements OnInit { | |||
389 | if (res === false) return | 390 | if (res === false) return |
390 | 391 | ||
391 | this.videoService.removeVideo(abuse.video.id) | 392 | this.videoService.removeVideo(abuse.video.id) |
392 | .subscribe( | 393 | .subscribe({ |
393 | () => { | 394 | next: () => { |
394 | this.notifier.success($localize`Video deleted.`) | 395 | this.notifier.success($localize`Video deleted.`) |
395 | 396 | ||
396 | this.updateAbuseState(abuse, AbuseState.ACCEPTED) | 397 | this.updateAbuseState(abuse, AbuseState.ACCEPTED) |
397 | }, | 398 | }, |
398 | 399 | ||
399 | err => this.notifier.error(err.message) | 400 | error: err => this.notifier.error(err.message) |
400 | ) | 401 | }) |
401 | } | 402 | } |
402 | } | 403 | } |
403 | ] | 404 | ] |
@@ -424,15 +425,15 @@ export class AbuseListTableComponent extends RestTable implements OnInit { | |||
424 | if (res === false) return | 425 | if (res === false) return |
425 | 426 | ||
426 | this.commentService.deleteVideoComment(abuse.comment.video.id, abuse.comment.id) | 427 | this.commentService.deleteVideoComment(abuse.comment.video.id, abuse.comment.id) |
427 | .subscribe( | 428 | .subscribe({ |
428 | () => { | 429 | next: () => { |
429 | this.notifier.success($localize`Comment deleted.`) | 430 | this.notifier.success($localize`Comment deleted.`) |
430 | 431 | ||
431 | this.updateAbuseState(abuse, AbuseState.ACCEPTED) | 432 | this.updateAbuseState(abuse, AbuseState.ACCEPTED) |
432 | }, | 433 | }, |
433 | 434 | ||
434 | err => this.notifier.error(err.message) | 435 | error: err => this.notifier.error(err.message) |
435 | ) | 436 | }) |
436 | } | 437 | } |
437 | } | 438 | } |
438 | ] | 439 | ] |
@@ -440,25 +441,25 @@ export class AbuseListTableComponent extends RestTable implements OnInit { | |||
440 | 441 | ||
441 | private muteAccountHelper (account: Account) { | 442 | private muteAccountHelper (account: Account) { |
442 | this.blocklistService.blockAccountByInstance(account) | 443 | this.blocklistService.blockAccountByInstance(account) |
443 | .subscribe( | 444 | .subscribe({ |
444 | () => { | 445 | next: () => { |
445 | this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`) | 446 | this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`) |
446 | account.mutedByInstance = true | 447 | account.mutedByInstance = true |
447 | }, | 448 | }, |
448 | 449 | ||
449 | err => this.notifier.error(err.message) | 450 | error: err => this.notifier.error(err.message) |
450 | ) | 451 | }) |
451 | } | 452 | } |
452 | 453 | ||
453 | private muteServerHelper (host: string) { | 454 | private muteServerHelper (host: string) { |
454 | this.blocklistService.blockServerByInstance(host) | 455 | this.blocklistService.blockServerByInstance(host) |
455 | .subscribe( | 456 | .subscribe({ |
456 | () => { | 457 | next: () => { |
457 | this.notifier.success($localize`Server ${host} muted by the instance.`) | 458 | this.notifier.success($localize`Server ${host} muted by the instance.`) |
458 | }, | 459 | }, |
459 | 460 | ||
460 | err => this.notifier.error(err.message) | 461 | error: err => this.notifier.error(err.message) |
461 | ) | 462 | }) |
462 | } | 463 | } |
463 | 464 | ||
464 | private toHtml (text: string) { | 465 | private toHtml (text: string) { |