diff options
Diffstat (limited to 'client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts')
-rw-r--r-- | client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts index 5e48cf24f..9858cbce2 100644 --- a/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts +++ b/client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts | |||
@@ -15,6 +15,7 @@ import { buildVideoLink, buildVideoEmbed } from 'src/assets/player/utils' | |||
15 | import { getAbsoluteAPIUrl } from '@app/shared/misc/utils' | 15 | import { getAbsoluteAPIUrl } from '@app/shared/misc/utils' |
16 | import { DomSanitizer } from '@angular/platform-browser' | 16 | import { DomSanitizer } from '@angular/platform-browser' |
17 | import { BlocklistService } from '@app/shared/blocklist' | 17 | import { BlocklistService } from '@app/shared/blocklist' |
18 | import { VideoService } from '@app/shared/video/video.service' | ||
18 | 19 | ||
19 | @Component({ | 20 | @Component({ |
20 | selector: 'my-video-abuse-list', | 21 | selector: 'my-video-abuse-list', |
@@ -26,7 +27,8 @@ export class VideoAbuseListComponent extends RestTable implements OnInit { | |||
26 | 27 | ||
27 | videoAbuses: (VideoAbuse & { moderationCommentHtml?: string, reasonHtml?: string })[] = [] | 28 | videoAbuses: (VideoAbuse & { moderationCommentHtml?: string, reasonHtml?: string })[] = [] |
28 | totalRecords = 0 | 29 | totalRecords = 0 |
29 | rowsPerPage = 10 | 30 | rowsPerPageOptions = [ 20, 50, 100 ] |
31 | rowsPerPage = this.rowsPerPageOptions[0] | ||
30 | sort: SortMeta = { field: 'createdAt', order: 1 } | 32 | sort: SortMeta = { field: 'createdAt', order: 1 } |
31 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | 33 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } |
32 | 34 | ||
@@ -36,6 +38,7 @@ export class VideoAbuseListComponent extends RestTable implements OnInit { | |||
36 | private notifier: Notifier, | 38 | private notifier: Notifier, |
37 | private videoAbuseService: VideoAbuseService, | 39 | private videoAbuseService: VideoAbuseService, |
38 | private blocklistService: BlocklistService, | 40 | private blocklistService: BlocklistService, |
41 | private videoService: VideoService, | ||
39 | private videoBlacklistService: VideoBlacklistService, | 42 | private videoBlacklistService: VideoBlacklistService, |
40 | private confirmService: ConfirmService, | 43 | private confirmService: ConfirmService, |
41 | private i18n: I18n, | 44 | private i18n: I18n, |
@@ -78,10 +81,12 @@ export class VideoAbuseListComponent extends RestTable implements OnInit { | |||
78 | [ | 81 | [ |
79 | { | 82 | { |
80 | label: this.i18n('Actions for the video'), | 83 | label: this.i18n('Actions for the video'), |
81 | isHeader: true | 84 | isHeader: true, |
85 | isDisplayed: videoAbuse => !videoAbuse.video.deleted | ||
82 | }, | 86 | }, |
83 | { | 87 | { |
84 | label: this.i18n('Blacklist video'), | 88 | label: this.i18n('Blacklist video'), |
89 | isDisplayed: videoAbuse => !videoAbuse.video.deleted, | ||
85 | handler: videoAbuse => { | 90 | handler: videoAbuse => { |
86 | this.videoBlacklistService.blacklistVideo(videoAbuse.video.id, undefined, true) | 91 | this.videoBlacklistService.blacklistVideo(videoAbuse.video.id, undefined, true) |
87 | .subscribe( | 92 | .subscribe( |
@@ -94,6 +99,48 @@ export class VideoAbuseListComponent extends RestTable implements OnInit { | |||
94 | err => this.notifier.error(err.message) | 99 | err => this.notifier.error(err.message) |
95 | ) | 100 | ) |
96 | } | 101 | } |
102 | }, | ||
103 | { | ||
104 | label: this.i18n('Delete video'), | ||
105 | isDisplayed: videoAbuse => !videoAbuse.video.deleted, | ||
106 | handler: async videoAbuse => { | ||
107 | const res = await this.confirmService.confirm(this.i18n('Do you really want to delete this video?'), this.i18n('Delete')) | ||
108 | if (res === false) return | ||
109 | |||
110 | this.videoService.removeVideo(videoAbuse.video.id) | ||
111 | .subscribe( | ||
112 | () => { | ||
113 | this.notifier.success(this.i18n('Video deleted.')) | ||
114 | |||
115 | this.updateVideoAbuseState(videoAbuse, VideoAbuseState.ACCEPTED) | ||
116 | }, | ||
117 | |||
118 | err => this.notifier.error(err.message) | ||
119 | ) | ||
120 | } | ||
121 | } | ||
122 | ], | ||
123 | [ | ||
124 | { | ||
125 | label: this.i18n('Actions for the reporter'), | ||
126 | isHeader: true | ||
127 | }, | ||
128 | { | ||
129 | label: this.i18n('Mute reporter'), | ||
130 | handler: async videoAbuse => { | ||
131 | const account = videoAbuse.reporterAccount as Account | ||
132 | |||
133 | this.blocklistService.blockAccountByInstance(account) | ||
134 | .subscribe( | ||
135 | () => { | ||
136 | this.notifier.success(this.i18n('Account {{nameWithHost}} muted by the instance.', { nameWithHost: account.nameWithHost })) | ||
137 | |||
138 | account.mutedByInstance = true | ||
139 | }, | ||
140 | |||
141 | err => this.notifier.error(err.message) | ||
142 | ) | ||
143 | } | ||
97 | } | 144 | } |
98 | ] | 145 | ] |
99 | ] | 146 | ] |
@@ -180,7 +227,8 @@ export class VideoAbuseListComponent extends RestTable implements OnInit { | |||
180 | Object.assign(abuse, { | 227 | Object.assign(abuse, { |
181 | reasonHtml: await this.toHtml(abuse.reason), | 228 | reasonHtml: await this.toHtml(abuse.reason), |
182 | moderationCommentHtml: await this.toHtml(abuse.moderationComment), | 229 | moderationCommentHtml: await this.toHtml(abuse.moderationComment), |
183 | embedHtml: this.sanitizer.bypassSecurityTrustHtml(this.getVideoEmbed(abuse)) | 230 | embedHtml: this.sanitizer.bypassSecurityTrustHtml(this.getVideoEmbed(abuse)), |
231 | reporterAccount: new Account(abuse.reporterAccount) | ||
184 | }) | 232 | }) |
185 | } | 233 | } |
186 | 234 | ||