2020-07-27 09:40:30 +00:00
|
|
|
import * as debug from 'debug'
|
|
|
|
import truncate from 'lodash-es/truncate'
|
|
|
|
import { SortMeta } from 'primeng/api'
|
2021-05-03 12:33:34 +00:00
|
|
|
import { Component, Input, OnInit, ViewChild } from '@angular/core'
|
2020-11-16 13:47:05 +00:00
|
|
|
import { ActivatedRoute, Router } from '@angular/router'
|
2020-07-27 09:40:30 +00:00
|
|
|
import { ConfirmService, MarkdownService, Notifier, RestPagination, RestTable } from '@app/core'
|
|
|
|
import { Account, Actor, DropdownAction, Video, VideoService } from '@app/shared/shared-main'
|
|
|
|
import { AbuseService, BlocklistService, VideoBlockService } from '@app/shared/shared-moderation'
|
|
|
|
import { VideoCommentService } from '@app/shared/shared-video-comment'
|
2022-07-15 13:30:14 +00:00
|
|
|
import { logger } from '@root-helpers/logger'
|
2020-07-27 09:40:30 +00:00
|
|
|
import { AbuseState, AdminAbuse } from '@shared/models'
|
2021-05-03 12:33:34 +00:00
|
|
|
import { AdvancedInputFilter } from '../shared-forms'
|
2020-07-27 09:40:30 +00:00
|
|
|
import { AbuseMessageModalComponent } from './abuse-message-modal.component'
|
|
|
|
import { ModerationCommentModalComponent } from './moderation-comment-modal.component'
|
|
|
|
import { ProcessedAbuse } from './processed-abuse.model'
|
|
|
|
|
2022-07-15 13:30:14 +00:00
|
|
|
const debugLogger = debug('peertube:moderation:AbuseListTableComponent')
|
2020-07-27 09:40:30 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'my-abuse-list-table',
|
|
|
|
templateUrl: './abuse-list-table.component.html',
|
|
|
|
styleUrls: [ '../shared-moderation/moderation.scss', './abuse-list-table.component.scss' ]
|
|
|
|
})
|
2021-05-03 12:33:34 +00:00
|
|
|
export class AbuseListTableComponent extends RestTable implements OnInit {
|
2020-07-27 09:40:30 +00:00
|
|
|
@Input() viewType: 'admin' | 'user'
|
|
|
|
|
|
|
|
@ViewChild('abuseMessagesModal', { static: true }) abuseMessagesModal: AbuseMessageModalComponent
|
|
|
|
@ViewChild('moderationCommentModal', { static: true }) moderationCommentModal: ModerationCommentModalComponent
|
|
|
|
|
|
|
|
abuses: ProcessedAbuse[] = []
|
|
|
|
totalRecords = 0
|
|
|
|
sort: SortMeta = { field: 'createdAt', order: 1 }
|
|
|
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
|
|
|
|
|
|
|
abuseActions: DropdownAction<ProcessedAbuse>[][] = []
|
|
|
|
|
2021-05-03 09:06:19 +00:00
|
|
|
inputFilters: AdvancedInputFilter[] = [
|
|
|
|
{
|
2021-10-20 07:05:43 +00:00
|
|
|
title: $localize`Advanced filters`,
|
|
|
|
children: [
|
|
|
|
{
|
2021-11-03 13:23:55 +00:00
|
|
|
value: 'state:pending',
|
2021-10-20 07:05:43 +00:00
|
|
|
label: $localize`Unsolved reports`
|
|
|
|
},
|
|
|
|
{
|
2021-11-03 13:23:55 +00:00
|
|
|
value: 'state:accepted',
|
2021-10-20 07:05:43 +00:00
|
|
|
label: $localize`Accepted reports`
|
|
|
|
},
|
|
|
|
{
|
2021-11-03 13:23:55 +00:00
|
|
|
value: 'state:rejected',
|
2021-10-20 07:05:43 +00:00
|
|
|
label: $localize`Refused reports`
|
|
|
|
},
|
|
|
|
{
|
2021-11-03 13:23:55 +00:00
|
|
|
value: 'videoIs:blacklisted',
|
2021-10-20 07:05:43 +00:00
|
|
|
label: $localize`Reports with blocked videos`
|
|
|
|
},
|
|
|
|
{
|
2021-11-03 13:23:55 +00:00
|
|
|
value: 'videoIs:deleted',
|
2021-10-20 07:05:43 +00:00
|
|
|
label: $localize`Reports with deleted videos`
|
|
|
|
}
|
|
|
|
]
|
2021-05-03 09:06:19 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2020-07-27 09:40:30 +00:00
|
|
|
constructor (
|
2020-11-16 13:47:05 +00:00
|
|
|
protected route: ActivatedRoute,
|
|
|
|
protected router: Router,
|
2020-07-27 09:40:30 +00:00
|
|
|
private notifier: Notifier,
|
|
|
|
private abuseService: AbuseService,
|
|
|
|
private blocklistService: BlocklistService,
|
|
|
|
private commentService: VideoCommentService,
|
|
|
|
private videoService: VideoService,
|
|
|
|
private videoBlocklistService: VideoBlockService,
|
|
|
|
private confirmService: ConfirmService,
|
2022-10-25 13:02:14 +00:00
|
|
|
private markdownRenderer: MarkdownService
|
2020-07-27 09:40:30 +00:00
|
|
|
) {
|
|
|
|
super()
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit () {
|
|
|
|
this.abuseActions = [
|
|
|
|
this.buildInternalActions(),
|
|
|
|
|
|
|
|
this.buildFlaggedAccountActions(),
|
|
|
|
|
|
|
|
this.buildCommentActions(),
|
|
|
|
|
|
|
|
this.buildVideoActions(),
|
|
|
|
|
|
|
|
this.buildAccountActions()
|
|
|
|
]
|
|
|
|
|
|
|
|
this.initialize()
|
|
|
|
}
|
|
|
|
|
|
|
|
isAdminView () {
|
|
|
|
return this.viewType === 'admin'
|
|
|
|
}
|
|
|
|
|
|
|
|
getIdentifier () {
|
|
|
|
return 'AbuseListTableComponent'
|
|
|
|
}
|
|
|
|
|
|
|
|
openModerationCommentModal (abuse: AdminAbuse) {
|
|
|
|
this.moderationCommentModal.openModal(abuse)
|
|
|
|
}
|
|
|
|
|
|
|
|
onModerationCommentUpdated () {
|
2021-05-03 12:33:34 +00:00
|
|
|
this.reloadData()
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
isAbuseAccepted (abuse: AdminAbuse) {
|
|
|
|
return abuse.state.id === AbuseState.ACCEPTED
|
|
|
|
}
|
|
|
|
|
|
|
|
isAbuseRejected (abuse: AdminAbuse) {
|
|
|
|
return abuse.state.id === AbuseState.REJECTED
|
|
|
|
}
|
|
|
|
|
|
|
|
getVideoUrl (abuse: AdminAbuse) {
|
2021-06-28 15:30:59 +00:00
|
|
|
return Video.buildWatchUrl(abuse.video)
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getCommentUrl (abuse: AdminAbuse) {
|
2021-06-28 15:30:59 +00:00
|
|
|
return Video.buildWatchUrl(abuse.comment.video) + ';threadId=' + abuse.comment.threadId
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getAccountUrl (abuse: ProcessedAbuse) {
|
2021-04-28 21:45:23 +00:00
|
|
|
return '/a/' + abuse.flaggedAccount.nameWithHost
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async removeAbuse (abuse: AdminAbuse) {
|
2020-08-12 08:40:04 +00:00
|
|
|
const res = await this.confirmService.confirm($localize`Do you really want to delete this abuse report?`, $localize`Delete`)
|
2020-07-27 09:40:30 +00:00
|
|
|
if (res === false) return
|
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
this.abuseService.removeAbuse(abuse)
|
|
|
|
.subscribe({
|
|
|
|
next: () => {
|
|
|
|
this.notifier.success($localize`Abuse deleted.`)
|
|
|
|
this.reloadData()
|
|
|
|
},
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
error: err => this.notifier.error(err.message)
|
|
|
|
})
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
updateAbuseState (abuse: AdminAbuse, state: AbuseState) {
|
|
|
|
this.abuseService.updateAbuse(abuse, { state })
|
2021-08-17 09:27:47 +00:00
|
|
|
.subscribe({
|
|
|
|
next: () => this.reloadData(),
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
error: err => this.notifier.error(err.message)
|
|
|
|
})
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onCountMessagesUpdated (event: { abuseId: number, countMessages: number }) {
|
|
|
|
const abuse = this.abuses.find(a => a.id === event.abuseId)
|
|
|
|
|
|
|
|
if (!abuse) {
|
2022-07-15 13:30:14 +00:00
|
|
|
logger.error(`Cannot find abuse ${event.abuseId}`)
|
2020-07-27 09:40:30 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
abuse.countMessages = event.countMessages
|
|
|
|
}
|
|
|
|
|
|
|
|
openAbuseMessagesModal (abuse: AdminAbuse) {
|
|
|
|
this.abuseMessagesModal.openModal(abuse)
|
|
|
|
}
|
|
|
|
|
|
|
|
isLocalAbuse (abuse: AdminAbuse) {
|
|
|
|
if (this.viewType === 'user') return true
|
2022-01-20 09:52:50 +00:00
|
|
|
if (!abuse.reporterAccount) return false
|
2020-07-27 09:40:30 +00:00
|
|
|
|
|
|
|
return Actor.IS_LOCAL(abuse.reporterAccount.host)
|
|
|
|
}
|
|
|
|
|
2021-05-03 12:33:34 +00:00
|
|
|
protected reloadData () {
|
2022-07-15 13:30:14 +00:00
|
|
|
debugLogger('Loading data.')
|
2020-07-27 09:40:30 +00:00
|
|
|
|
|
|
|
const options = {
|
|
|
|
pagination: this.pagination,
|
|
|
|
sort: this.sort,
|
|
|
|
search: this.search
|
|
|
|
}
|
|
|
|
|
|
|
|
const observable = this.viewType === 'admin'
|
|
|
|
? this.abuseService.getAdminAbuses(options)
|
|
|
|
: this.abuseService.getUserAbuses(options)
|
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
return observable.subscribe({
|
|
|
|
next: async resultList => {
|
|
|
|
this.totalRecords = resultList.total
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
this.abuses = []
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
for (const a of resultList.data) {
|
|
|
|
const abuse = a as ProcessedAbuse
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
abuse.reasonHtml = await this.toHtml(abuse.reason)
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
if (abuse.moderationComment) {
|
|
|
|
abuse.moderationCommentHtml = await this.toHtml(abuse.moderationComment)
|
|
|
|
}
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
if (abuse.video) {
|
|
|
|
if (abuse.video.channel?.ownerAccount) {
|
|
|
|
abuse.video.channel.ownerAccount = new Account(abuse.video.channel.ownerAccount)
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
2021-08-17 09:27:47 +00:00
|
|
|
}
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
if (abuse.comment) {
|
|
|
|
if (abuse.comment.deleted) {
|
|
|
|
abuse.truncatedCommentHtml = abuse.commentHtml = $localize`Deleted comment`
|
|
|
|
} else {
|
|
|
|
const truncated = truncate(abuse.comment.text, { length: 100 })
|
2022-11-14 09:47:39 +00:00
|
|
|
abuse.truncatedCommentHtml = await this.markdownRenderer.textMarkdownToHTML({ markdown: truncated, withHtml: true })
|
|
|
|
abuse.commentHtml = await this.markdownRenderer.textMarkdownToHTML({ markdown: abuse.comment.text, withHtml: true })
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
2021-08-17 09:27:47 +00:00
|
|
|
}
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
if (abuse.reporterAccount) {
|
|
|
|
abuse.reporterAccount = new Account(abuse.reporterAccount)
|
|
|
|
}
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
if (abuse.flaggedAccount) {
|
|
|
|
abuse.flaggedAccount = new Account(abuse.flaggedAccount)
|
|
|
|
}
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
if (abuse.updatedAt === abuse.createdAt) delete abuse.updatedAt
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
this.abuses.push(abuse)
|
|
|
|
}
|
|
|
|
},
|
2020-07-27 09:40:30 +00:00
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
error: err => this.notifier.error(err.message)
|
|
|
|
})
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private buildInternalActions (): DropdownAction<ProcessedAbuse>[] {
|
|
|
|
return [
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Internal actions`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isHeader: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: this.isAdminView()
|
2020-08-12 08:40:04 +00:00
|
|
|
? $localize`Messages with reporter`
|
|
|
|
: $localize`Messages with moderators`,
|
2020-07-27 09:40:30 +00:00
|
|
|
handler: abuse => this.openAbuseMessagesModal(abuse),
|
|
|
|
isDisplayed: abuse => this.isLocalAbuse(abuse)
|
|
|
|
},
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Update internal note`,
|
2020-07-27 09:40:30 +00:00
|
|
|
handler: abuse => this.openModerationCommentModal(abuse),
|
|
|
|
isDisplayed: abuse => this.isAdminView() && !!abuse.moderationComment
|
|
|
|
},
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Mark as accepted`,
|
2020-07-27 09:40:30 +00:00
|
|
|
handler: abuse => this.updateAbuseState(abuse, AbuseState.ACCEPTED),
|
|
|
|
isDisplayed: abuse => this.isAdminView() && !this.isAbuseAccepted(abuse)
|
|
|
|
},
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Mark as rejected`,
|
2020-07-27 09:40:30 +00:00
|
|
|
handler: abuse => this.updateAbuseState(abuse, AbuseState.REJECTED),
|
|
|
|
isDisplayed: abuse => this.isAdminView() && !this.isAbuseRejected(abuse)
|
|
|
|
},
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Add internal note`,
|
2020-07-27 09:40:30 +00:00
|
|
|
handler: abuse => this.openModerationCommentModal(abuse),
|
|
|
|
isDisplayed: abuse => this.isAdminView() && !abuse.moderationComment
|
|
|
|
},
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Delete report`,
|
2022-10-25 13:02:14 +00:00
|
|
|
handler: abuse => this.removeAbuse(abuse),
|
|
|
|
isDisplayed: () => this.isAdminView()
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
private buildFlaggedAccountActions (): DropdownAction<ProcessedAbuse>[] {
|
|
|
|
if (!this.isAdminView()) return []
|
|
|
|
|
|
|
|
return [
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Actions for the flagged account`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isHeader: true,
|
|
|
|
isDisplayed: abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Mute account`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isDisplayed: abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video,
|
|
|
|
handler: abuse => this.muteAccountHelper(abuse.flaggedAccount)
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Mute server account`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isDisplayed: abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video,
|
|
|
|
handler: abuse => this.muteServerHelper(abuse.flaggedAccount.host)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
private buildAccountActions (): DropdownAction<ProcessedAbuse>[] {
|
|
|
|
if (!this.isAdminView()) return []
|
|
|
|
|
|
|
|
return [
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Actions for the reporter`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isHeader: true,
|
|
|
|
isDisplayed: abuse => !!abuse.reporterAccount
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Mute reporter`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isDisplayed: abuse => !!abuse.reporterAccount,
|
|
|
|
handler: abuse => this.muteAccountHelper(abuse.reporterAccount)
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Mute server`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isDisplayed: abuse => abuse.reporterAccount && !abuse.reporterAccount.userId,
|
|
|
|
handler: abuse => this.muteServerHelper(abuse.reporterAccount.host)
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
private buildVideoActions (): DropdownAction<ProcessedAbuse>[] {
|
|
|
|
if (!this.isAdminView()) return []
|
|
|
|
|
|
|
|
return [
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Actions for the video`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isHeader: true,
|
|
|
|
isDisplayed: abuse => abuse.video && !abuse.video.deleted
|
|
|
|
},
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Block video`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isDisplayed: abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted,
|
|
|
|
handler: abuse => {
|
2021-11-17 10:18:49 +00:00
|
|
|
this.videoBlocklistService.blockVideo([ { videoId: abuse.video.id, unfederate: abuse.video.channel.isLocal } ])
|
2021-08-17 09:27:47 +00:00
|
|
|
.subscribe({
|
|
|
|
next: () => {
|
2020-08-12 08:40:04 +00:00
|
|
|
this.notifier.success($localize`Video blocked.`)
|
2020-07-27 09:40:30 +00:00
|
|
|
|
|
|
|
this.updateAbuseState(abuse, AbuseState.ACCEPTED)
|
|
|
|
},
|
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
error: err => this.notifier.error(err.message)
|
|
|
|
})
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Unblock video`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isDisplayed: abuse => abuse.video && !abuse.video.deleted && abuse.video.blacklisted,
|
|
|
|
handler: abuse => {
|
|
|
|
this.videoBlocklistService.unblockVideo(abuse.video.id)
|
2021-08-17 09:27:47 +00:00
|
|
|
.subscribe({
|
|
|
|
next: () => {
|
2020-08-12 08:40:04 +00:00
|
|
|
this.notifier.success($localize`Video unblocked.`)
|
2020-07-27 09:40:30 +00:00
|
|
|
|
|
|
|
this.updateAbuseState(abuse, AbuseState.ACCEPTED)
|
|
|
|
},
|
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
error: err => this.notifier.error(err.message)
|
|
|
|
})
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Delete video`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isDisplayed: abuse => abuse.video && !abuse.video.deleted,
|
|
|
|
handler: async abuse => {
|
|
|
|
const res = await this.confirmService.confirm(
|
2020-08-12 08:40:04 +00:00
|
|
|
$localize`Do you really want to delete this video?`,
|
|
|
|
$localize`Delete`
|
2020-07-27 09:40:30 +00:00
|
|
|
)
|
|
|
|
if (res === false) return
|
|
|
|
|
|
|
|
this.videoService.removeVideo(abuse.video.id)
|
2021-08-17 09:27:47 +00:00
|
|
|
.subscribe({
|
|
|
|
next: () => {
|
2020-08-12 08:40:04 +00:00
|
|
|
this.notifier.success($localize`Video deleted.`)
|
2020-07-27 09:40:30 +00:00
|
|
|
|
|
|
|
this.updateAbuseState(abuse, AbuseState.ACCEPTED)
|
|
|
|
},
|
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
error: err => this.notifier.error(err.message)
|
|
|
|
})
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
private buildCommentActions (): DropdownAction<ProcessedAbuse>[] {
|
|
|
|
if (!this.isAdminView()) return []
|
|
|
|
|
|
|
|
return [
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Actions for the comment`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isHeader: true,
|
|
|
|
isDisplayed: abuse => abuse.comment && !abuse.comment.deleted
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
2020-08-12 08:40:04 +00:00
|
|
|
label: $localize`Delete comment`,
|
2020-07-27 09:40:30 +00:00
|
|
|
isDisplayed: abuse => abuse.comment && !abuse.comment.deleted,
|
|
|
|
handler: async abuse => {
|
|
|
|
const res = await this.confirmService.confirm(
|
2020-08-12 08:40:04 +00:00
|
|
|
$localize`Do you really want to delete this comment?`,
|
|
|
|
$localize`Delete`
|
2020-07-27 09:40:30 +00:00
|
|
|
)
|
|
|
|
if (res === false) return
|
|
|
|
|
|
|
|
this.commentService.deleteVideoComment(abuse.comment.video.id, abuse.comment.id)
|
2021-08-17 09:27:47 +00:00
|
|
|
.subscribe({
|
|
|
|
next: () => {
|
2020-08-12 08:40:04 +00:00
|
|
|
this.notifier.success($localize`Comment deleted.`)
|
2020-07-27 09:40:30 +00:00
|
|
|
|
|
|
|
this.updateAbuseState(abuse, AbuseState.ACCEPTED)
|
|
|
|
},
|
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
error: err => this.notifier.error(err.message)
|
|
|
|
})
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
private muteAccountHelper (account: Account) {
|
|
|
|
this.blocklistService.blockAccountByInstance(account)
|
2021-08-17 09:27:47 +00:00
|
|
|
.subscribe({
|
|
|
|
next: () => {
|
2020-08-12 08:40:04 +00:00
|
|
|
this.notifier.success($localize`Account ${account.nameWithHost} muted by the instance.`)
|
2020-07-27 09:40:30 +00:00
|
|
|
account.mutedByInstance = true
|
|
|
|
},
|
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
error: err => this.notifier.error(err.message)
|
|
|
|
})
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private muteServerHelper (host: string) {
|
|
|
|
this.blocklistService.blockServerByInstance(host)
|
2021-08-17 09:27:47 +00:00
|
|
|
.subscribe({
|
|
|
|
next: () => {
|
2020-08-12 08:40:04 +00:00
|
|
|
this.notifier.success($localize`Server ${host} muted by the instance.`)
|
2020-07-27 09:40:30 +00:00
|
|
|
},
|
|
|
|
|
2021-08-17 09:27:47 +00:00
|
|
|
error: err => this.notifier.error(err.message)
|
|
|
|
})
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private toHtml (text: string) {
|
2022-11-14 09:47:39 +00:00
|
|
|
return this.markdownRenderer.textMarkdownToHTML({ markdown: text })
|
2020-07-27 09:40:30 +00:00
|
|
|
}
|
|
|
|
}
|