Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add bulk actions to abuse list

Chocobozzza93cca115b4e
diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html
index bc62c8a582..baca58c33a 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html
+++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html
@@ -7,6 +7,7 @@
[dataLoader]="dataLoader"
columnConfig="false"
[inputFilters]="inputFilters"
+ [bulkActions]="bulkActions"
searchInput="true"
>
<ng-template #totalTitle let-totalRecords>
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 ace7543e9f..e1d360658c 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
@@ -68,6 +68,7 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
readonly moderationCommentModal = viewChild<ModerationCommentModalComponent>('moderationCommentModal')
abuseActions: DropdownAction<ProcessedAbuse>[][] = []
+ bulkActions: DropdownAction<ProcessedAbuse[]>[][] = []
inputFilters: AdvancedFilterDef<DataLoaderParameter>[] = [
{
@@ -162,6 +163,8 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
this.abuseActions = viewType === 'admin'
? await this.hooks.wrapObject(abuseActions, 'admin-comments', 'filter:admin-abuse-list.actions.create.result')
: abuseActions
+
+ this.bulkActions = this.buildBulkActions()
}
ngOnDestroy () {
@@ -174,8 +177,8 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
return this.viewType() === 'admin'
}
- openModerationCommentModal (abuse: AdminAbuse) {
- this.moderationCommentModal().openModal(abuse)
+ openModerationCommentModal (abuses: AdminAbuse[]) {
+ this.moderationCommentModal().openModal(abuses)
}
onModerationCommentUpdated () {
@@ -202,23 +205,8 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
return '/a/' + abuse.flaggedAccount.nameWithHost
}
- async removeAbuse (abuse: AdminAbuse) {
- const res = await this.confirmService.confirm($localize`Do you really want to delete this abuse report?`, $localize`Delete`)
- if (res === false) return
-
- this.abuseService.removeAbuse(abuse)
- .subscribe({
- next: () => {
- this.notifier.success($localize`Abuse deleted.`)
- this.table().loadData()
- },
-
- error: err => this.notifier.handleError(err)
- })
- }
-
updateAbuseState (abuse: AdminAbuse, state: AbuseStateType) {
- this.abuseService.updateAbuse(abuse, { state })
+ this.abuseService.updateAbuse([ abuse ], { state })
.subscribe({
next: () => this.table().loadData(),
@@ -325,7 +313,7 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
},
{
label: $localize`Update internal note`,
- handler: abuse => this.openModerationCommentModal(abuse),
+ handler: abuse => this.openModerationCommentModal([ abuse ]),
isDisplayed: abuse => this.isAdminView() && !!abuse.moderationComment
},
{
@@ -340,17 +328,103 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
},
{
label: $localize`Add internal note`,
- handler: abuse => this.openModerationCommentModal(abuse),
+ handler: abuse => this.openModerationCommentModal([ abuse ]),
isDisplayed: abuse => this.isAdminView() && !abuse.moderationComment
},
{
label: $localize`Delete report`,
- handler: abuse => this.removeAbuse(abuse),
+ handler: abuse => this.removeAbuses([ abuse ]),
isDisplayed: () => this.isAdminView()
}
]
}
+ private buildBulkActions (): DropdownAction<ProcessedAbuse[]>[][] {
+ return [
+ [
+ {
+ label: $localize`Update internal note`,
+ handler: abuses => this.openModerationCommentModal(abuses),
+ isDisplayed: abuses => this.isAdminView() && abuses.every(abuse => !!abuse.moderationComment)
+ },
+ {
+ label: $localize`Mark as accepted`,
+ handler: abuses => this.updateAbusesState(abuses, AbuseState.ACCEPTED),
+ isDisplayed: abuses => this.isAdminView() && abuses.every(abuse => !this.isAbuseAccepted(abuse))
+ },
+ {
+ label: $localize`Mark as rejected`,
+ handler: abuses => this.updateAbusesState(abuses, AbuseState.REJECTED),
+ isDisplayed: abuses => this.isAdminView() && abuses.every(abuse => !this.isAbuseRejected(abuse))
+ },
+ {
+ label: $localize`Add internal note`,
+ handler: abuses => this.openModerationCommentModal(abuses),
+ isDisplayed: abuses => this.isAdminView() && abuses.every(abuse => !abuse.moderationComment)
+ },
+ {
+ label: $localize`Delete report`,
+ handler: abuses => this.removeAbuses(abuses),
+ isDisplayed: () => this.isAdminView()
+ }
+ ],
+ [
+ {
+ label: $localize`Mute account`,
+ handler: abuses => this.muteFlaggedAccounts(abuses),
+ isDisplayed: abuses => {
+ return this.isAdminView() && abuses.every(abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video)
+ }
+ },
+ {
+ label: $localize`Mute server account`,
+ handler: abuses => this.muteFlaggedAccountServers(abuses),
+ isDisplayed: abuses => {
+ return this.isAdminView() && abuses.every(abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video)
+ }
+ },
+ {
+ label: $localize`Mute reporter`,
+ handler: abuses => this.muteReporters(abuses),
+ isDisplayed: abuses => this.isAdminView() && abuses.every(abuse => !!abuse.reporterAccount)
+ },
+ {
+ label: $localize`Mute reporter server`,
+ handler: abuses => this.muteReporterServers(abuses),
+ isDisplayed: abuses => {
+ return this.isAdminView() && abuses.every(abuse => abuse.reporterAccount && !abuse.reporterAccount.userId)
+ }
+ }
+ ],
+ [
+ {
+ label: $localize`Block video`,
+ handler: abuses => this.blockAbuseVideos(abuses),
+ isDisplayed: abuses => {
+ return this.isAdminView() && abuses.every(abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted)
+ }
+ },
+ {
+ label: $localize`Unblock video`,
+ handler: abuses => this.unblockAbuseVideos(abuses),
+ isDisplayed: abuses => {
+ return this.isAdminView() && abuses.every(abuse => abuse.video && !abuse.video.deleted && abuse.video.blacklisted)
+ }
+ },
+ {
+ label: $localize`Delete video`,
+ handler: abuses => this.deleteAbuseVideos(abuses),
+ isDisplayed: abuses => this.isAdminView() && abuses.every(abuse => abuse.video && !abuse.video.deleted)
+ },
+ {
+ label: $localize`Delete comment`,
+ handler: abuses => this.deleteAbuseComments(abuses),
+ isDisplayed: abuses => this.isAdminView() && abuses.every(abuse => abuse.comment && !abuse.comment.deleted)
+ }
+ ]
+ ]
+ }
+
private buildFlaggedAccountActions (): DropdownAction<ProcessedAbuse>[] {
if (!this.isAdminView()) return []
@@ -364,13 +438,13 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
{
label: $localize`Mute account`,
isDisplayed: abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video,
- handler: abuse => this.muteAccountHelper(abuse.flaggedAccount)
+ handler: abuse => this.muteFlaggedAccounts([ abuse ])
},
{
label: $localize`Mute server account`,
isDisplayed: abuse => abuse.flaggedAccount && !abuse.comment && !abuse.video,
- handler: abuse => this.muteServerHelper(abuse.flaggedAccount.host)
+ handler: abuse => this.muteFlaggedAccountServers([ abuse ])
}
]
}
@@ -388,13 +462,13 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
{
label: $localize`Mute reporter`,
isDisplayed: abuse => !!abuse.reporterAccount,
- handler: abuse => this.muteAccountHelper(abuse.reporterAccount)
+ handler: abuse => this.muteReporters([ abuse ])
},
{
label: $localize`Mute server`,
isDisplayed: abuse => abuse.reporterAccount && !abuse.reporterAccount.userId,
- handler: abuse => this.muteServerHelper(abuse.reporterAccount.host)
+ handler: abuse => this.muteReporterServers([ abuse ])
}
]
}
@@ -411,56 +485,17 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
{
label: $localize`Block video`,
isDisplayed: abuse => abuse.video && !abuse.video.deleted && !abuse.video.blacklisted,
- handler: abuse => {
- this.videoBlocklistService.blockVideos([ { videoId: abuse.video.id, unfederate: abuse.video.channel.isLocal } ])
- .subscribe({
- next: () => {
- this.notifier.success($localize`Video blocked.`)
-
- this.updateAbuseState(abuse, AbuseState.ACCEPTED)
- },
-
- error: err => this.notifier.handleError(err)
- })
- }
+ handler: abuse => this.blockAbuseVideos([ abuse ])
},
{
label: $localize`Unblock video`,
isDisplayed: abuse => abuse.video && !abuse.video.deleted && abuse.video.blacklisted,
- handler: abuse => {
- this.videoBlocklistService.unblockVideos(abuse.video.id)
- .subscribe({
- next: () => {
- this.notifier.success($localize`Video unblocked.`)
-
- this.updateAbuseState(abuse, AbuseState.ACCEPTED)
- },
-
- error: err => this.notifier.handleError(err)
- })
- }
+ handler: abuse => this.unblockAbuseVideos([ abuse ])
},
{
label: $localize`Delete video`,
isDisplayed: abuse => abuse.video && !abuse.video.deleted,
- handler: async abuse => {
- const res = await this.confirmService.confirm(
- $localize`Do you really want to delete this video?`,
- $localize`Delete`
- )
- if (res === false) return
-
- this.videoService.removeVideo(abuse.video.id)
- .subscribe({
- next: () => {
- this.notifier.success($localize`Video deleted.`)
-
- this.updateAbuseState(abuse, AbuseState.ACCEPTED)
- },
-
- error: err => this.notifier.handleError(err)
- })
- }
+ handler: abuse => this.deleteAbuseVideos([ abuse ])
}
]
}
@@ -478,45 +513,216 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {
{
label: $localize`Delete comment`,
isDisplayed: abuse => abuse.comment && !abuse.comment.deleted,
- handler: async abuse => {
- const res = await this.confirmService.confirm(
- $localize`Do you really want to delete this comment?`,
- $localize`Delete`
+ handler: abuse => this.deleteAbuseComments([ abuse ])
+ }
+ ]
+ }
+
+ private removeAbuses (abuses: AdminAbuse[]) {
+ this.abuseService.removeAbuse(abuses)
+ .subscribe({
+ next: () => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Abuse deleted.} other {{count} abuses deleted.}}`,
+ { count: abuses.length }
+ )
)
- if (res === false) return
- this.commentService.deleteVideoComment(abuse.comment.video.id, abuse.comment.id)
- .subscribe({
- next: () => {
- this.notifier.success($localize`Comment deleted.`)
+ this.table().loadData()
+ },
- this.updateAbuseState(abuse, AbuseState.ACCEPTED)
- },
+ error: err => this.notifier.handleError(err)
+ })
+ }
- error: err => this.notifier.handleError(err)
- })
- }
- }
- ]
+ private updateAbusesState (abuses: AdminAbuse[], state: AbuseStateType) {
+ this.abuseService.updateAbuse(abuses, { state })
+ .subscribe({
+ next: () => {
+ this.table().loadData()
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
}
- private muteAccountHelper (account: Account) {
- this.blocklistService.blockAccountByInstance(account)
+ private muteFlaggedAccounts (abuses: ProcessedAbuse[]) {
+ const accounts = abuses.map(abuse => abuse.flaggedAccount)
+
+ this.blocklistService.blockAccountByInstance(accounts)
.subscribe({
next: () => {
- this.notifier.success($localize`Account ${account.nameWithHost} muted by your platform.`)
- account.mutedByInstance = true
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Flagged account muted.} other {{count} flagged accounts muted.}}`,
+ { count: accounts.length }
+ )
+ )
+
+ this.table().loadData()
},
error: err => this.notifier.handleError(err)
})
}
- private muteServerHelper (host: string) {
- this.blocklistService.blockServerByInstance(host)
+ private muteFlaggedAccountServers (abuses: ProcessedAbuse[]) {
+ const hosts = abuses.map(abuse => abuse.flaggedAccount.host)
+
+ this.blocklistService.blockServerByInstance(hosts)
.subscribe({
next: () => {
- this.notifier.success($localize`${host} muted by your platform.`)
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Flagged account server muted.} other {{count} flagged account servers muted.}}`,
+ { count: hosts.length }
+ )
+ )
+
+ this.table().loadData()
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ private muteReporters (abuses: ProcessedAbuse[]) {
+ const accounts = abuses.map(abuse => abuse.reporterAccount)
+
+ this.blocklistService.blockAccountByInstance(accounts)
+ .subscribe({
+ next: () => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Reporter muted.} other {{count} reporters muted.}}`,
+ { count: accounts.length }
+ )
+ )
+
+ for (const account of accounts) {
+ account.mutedByInstance = true
+ }
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ private muteReporterServers (abuses: ProcessedAbuse[]) {
+ const hosts = abuses.map(abuse => abuse.reporterAccount.host)
+
+ this.blocklistService.blockServerByInstance(hosts)
+ .subscribe({
+ next: () => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Reporter server muted.} other {{count} reporter servers muted.}}`,
+ { count: hosts.length }
+ )
+ )
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ private blockAbuseVideos (abuses: ProcessedAbuse[]) {
+ const videos = abuses.map(abuse => ({
+ videoId: abuse.video.id,
+ unfederate: abuse.video.channel.isLocal
+ }))
+
+ this.videoBlocklistService.blockVideos(videos)
+ .subscribe({
+ next: () => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Video blocked.} other {{count} videos blocked.}}`,
+ { count: videos.length }
+ )
+ )
+
+ this.updateAbusesState(abuses, AbuseState.ACCEPTED)
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ private unblockAbuseVideos (abuses: ProcessedAbuse[]) {
+ const videoIds = abuses.map(abuse => abuse.video.id)
+
+ this.videoBlocklistService.unblockVideos(videoIds)
+ .subscribe({
+ next: () => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Video unblocked.} other {{count} videos unblocked.}}`,
+ { count: videoIds.length }
+ )
+ )
+
+ this.updateAbusesState(abuses, AbuseState.ACCEPTED)
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ private async deleteAbuseVideos (abuses: ProcessedAbuse[]) {
+ const res = await this.confirmService.confirm(
+ formatICU(
+ $localize`Do you really want to delete {count, plural, =1 {this video?} other {{count} videos?}}`,
+ { count: abuses.length }
+ ),
+ $localize`Delete`
+ )
+ if (res === false) return
+
+ this.videoService.removeVideo(abuses.map(abuse => abuse.video.id))
+ .subscribe({
+ next: () => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Video deleted.} other {{count} videos deleted.}}`,
+ { count: abuses.length }
+ )
+ )
+
+ this.updateAbusesState(abuses, AbuseState.ACCEPTED)
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ private async deleteAbuseComments (abuses: ProcessedAbuse[]) {
+ const res = await this.confirmService.confirm(
+ formatICU(
+ $localize`Do you really want to delete {count, plural, =1 {this comment?} other {{count} comments?}}`,
+ { count: abuses.length }
+ ),
+ $localize`Delete`
+ )
+ if (res === false) return
+
+ this.commentService.deleteVideoComments(
+ abuses.map(abuse => ({
+ videoId: abuse.comment.video.id,
+ commentId: abuse.comment.id
+ }))
+ )
+ .subscribe({
+ next: () => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Comment deleted.} other {{count} comments deleted.}}`,
+ { count: abuses.length }
+ )
+ )
+
+ this.updateAbusesState(abuses, AbuseState.ACCEPTED)
},
error: err => this.notifier.handleError(err)
diff --git a/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.html b/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.html
index 258d7e2294..44c26983a9 100644
--- a/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.html
+++ b/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.html
@@ -1,6 +1,6 @@
<ng-template #modal>
<div class="modal-header">
- <h4 i18n class="modal-title">Moderation comment</h4>
+ <h4 class="modal-title">{{ getModalTitle() }}</h4>
<button class="border-0 p-0" title="Close this modal" i18n-title (click)="hide()">
<my-global-icon iconName="cross"></my-global-icon>
@@ -22,8 +22,12 @@
}
</div>
- <div class="form-group" i18n>
- This comment can only be seen by you or the other moderators.
+ <div class="form-group">
+ @if (hasMultipleAbuses()) {
+ <ng-container i18n>This comment will be set on all selected reports and can only be seen by moderators.</ng-container>
+ } @else {
+ <ng-container i18n>This comment can only be seen by you or the other moderators.</ng-container>
+ }
</div>
<div class="form-group inputs">
@@ -32,7 +36,7 @@
(click)="hide()" (key.enter)="hide()"
>
- <input type="submit" i18n-value value="Update this comment" class="peertube-button primary-button" [disabled]="!form.valid" />
+ <input type="submit" [value]="getSubmitLabel()" class="peertube-button primary-button" [disabled]="!form.valid" />
</div>
</form>
</div>
diff --git a/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts b/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts
index c16c1cb7cf..bd44080198 100644
--- a/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts
+++ b/client/src/app/shared/shared-abuse-list/moderation-comment-modal.component.ts
@@ -1,10 +1,12 @@
import { NgClass } from '@angular/common'
import { Component, OnInit, inject, output, viewChild } from '@angular/core'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
+import { formatICU } from '@app/helpers'
import { Notifier } from '@app/core'
import { FormReactive } from '@app/shared/shared-forms/form-reactive'
import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
+import { arrayify } from '@peertube/peertube-core-utils'
import { AdminAbuse } from '@peertube/peertube-models'
import { ABUSE_MODERATION_COMMENT_VALIDATOR } from '../form-validators/abuse-validators'
import { GlobalIconComponent } from '../shared-icons/global-icon.component'
@@ -25,7 +27,7 @@ export class ModerationCommentModalComponent extends FormReactive implements OnI
readonly modal = viewChild<NgbModal>('modal')
readonly commentUpdated = output<string>()
- private abuseToComment: AdminAbuse
+ abusesToComment: AdminAbuse[] = []
private openedModal: NgbModalRef
ngOnInit () {
@@ -34,28 +36,53 @@ export class ModerationCommentModalComponent extends FormReactive implements OnI
})
}
- openModal (abuseToComment: AdminAbuse) {
- this.abuseToComment = abuseToComment
+ openModal (abuseToCommentArg: AdminAbuse | AdminAbuse[]) {
+ this.abusesToComment = arrayify(abuseToCommentArg)
this.openedModal = this.modalService.open(this.modal(), { centered: true })
this.form.patchValue({
- moderationComment: this.abuseToComment.moderationComment
+ moderationComment: this.abusesToComment.length === 1
+ ? this.abusesToComment[0].moderationComment
+ : ''
})
}
hide () {
- this.abuseToComment = undefined
+ this.abusesToComment = []
this.openedModal.close()
this.form.reset()
}
+ hasMultipleAbuses () {
+ return this.abusesToComment.length > 1
+ }
+
+ getSubmitLabel () {
+ return formatICU(
+ $localize`{count, plural, =1 {Update this comment} other {Update all comments}}`,
+ { count: this.abusesToComment.length }
+ )
+ }
+
+ getModalTitle () {
+ return formatICU(
+ $localize`{count, plural, =1 {Moderation comment} other {Moderation comments}}`,
+ { count: this.abusesToComment.length }
+ )
+ }
+
banUser () {
const moderationComment: string = this.form.value['moderationComment']
- this.abuseService.updateAbuse(this.abuseToComment, { moderationComment })
+ this.abuseService.updateAbuse(this.abusesToComment, { moderationComment })
.subscribe({
next: () => {
- this.notifier.success($localize`Comment updated.`)
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Comment updated.} other {{count} comments updated.}}`,
+ { count: this.abusesToComment.length }
+ )
+ )
this.commentUpdated.emit(moderationComment)
this.hide()
diff --git a/client/src/app/shared/shared-moderation/abuse.service.ts b/client/src/app/shared/shared-moderation/abuse.service.ts
index b36d4be8f4..b3df70397e 100644
--- a/client/src/app/shared/shared-moderation/abuse.service.ts
+++ b/client/src/app/shared/shared-moderation/abuse.service.ts
@@ -12,10 +12,11 @@ import {
ResultList,
UserAbuse
} from '@peertube/peertube-models'
+import { arrayify } from '@peertube/peertube-core-utils'
import { omit } from 'lodash-es'
import { SortMeta } from 'primeng/api'
-import { Observable } from 'rxjs'
-import { catchError } from 'rxjs/operators'
+import { Observable, from } from 'rxjs'
+import { catchError, concatMap, toArray } from 'rxjs/operators'
import { environment } from '../../../environments/environment'
@Injectable()
@@ -85,18 +86,26 @@ export class AbuseService {
.pipe(catchError(res => this.restExtractor.handleError(res)))
}
- updateAbuse (abuse: AdminAbuse, abuseUpdate: AbuseUpdate) {
- const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id
+ updateAbuse (abuseArg: AdminAbuse | AdminAbuse[], abuseUpdate: AbuseUpdate) {
+ const abuses = arrayify(abuseArg)
- return this.authHttp.put(url, abuseUpdate)
- .pipe(catchError(res => this.restExtractor.handleError(res)))
+ return from(abuses)
+ .pipe(
+ concatMap(abuse => this.authHttp.put(AbuseService.BASE_ABUSE_URL + '/' + abuse.id, abuseUpdate)),
+ toArray(),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
- removeAbuse (abuse: AdminAbuse) {
- const url = AbuseService.BASE_ABUSE_URL + '/' + abuse.id
+ removeAbuse (abuseArg: AdminAbuse | AdminAbuse[]) {
+ const abuses = arrayify(abuseArg)
- return this.authHttp.delete(url)
- .pipe(catchError(res => this.restExtractor.handleError(res)))
+ return from(abuses)
+ .pipe(
+ concatMap(abuse => this.authHttp.delete(AbuseService.BASE_ABUSE_URL + '/' + abuse.id)),
+ toArray(),
+ catchError(res => this.restExtractor.handleError(res))
+ )
}
addAbuseMessage (abuse: UserAbuse, message: string) {
diff --git a/client/src/app/shared/shared-moderation/blocklist.service.ts b/client/src/app/shared/shared-moderation/blocklist.service.ts
index c57a44d31a..0b7858e45b 100644
--- a/client/src/app/shared/shared-moderation/blocklist.service.ts
+++ b/client/src/app/shared/shared-moderation/blocklist.service.ts
@@ -150,11 +150,15 @@ export class BlocklistService {
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
- blockServerByInstance (host: string) {
- const body = { host }
+ blockServerByInstance (hostsArg: string | string[]) {
+ const hosts = arrayify(hostsArg)
- return this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/servers', body)
- .pipe(catchError(err => this.restExtractor.handleError(err)))
+ return from(hosts)
+ .pipe(
+ concatMap(host => this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/servers', { host })),
+ toArray(),
+ catchError(err => this.restExtractor.handleError(err))
+ )
}
unblockServerByInstance (host: string) {