ActivityPub-federated video streaming platform using P2P directly in your web browser
Improve abuse table UX to check muted accounts
Chocobozzz8f5cf8bd6fe9
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.htmlindex baca58c33a..0c2c424769 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@@ -27,6 +27,8 @@</div></div></a>++ <my-account-block-badges class="d-inline-block ms-3" [account]="abuse.reporterAccount"></my-account-block-badges>} @else {<span i18n>Deleted account</span>}@@ -78,11 +80,15 @@</td>} @else if(abuse.flaggedAccount) {<td>- <a [href]="getAccountUrl(abuse)" class="table-account-link" target="_blank" rel="noopener noreferrer">- <span>{{ abuse.flaggedAccount.displayName }}</span>+ <div>+ <a [href]="getAccountUrl(abuse)" class="table-account-link d-inline-block" target="_blank" rel="noopener noreferrer">+ <div>{{ abuse.flaggedAccount.displayName }}</div>- <span class="account-flagged-handle">{{ abuse.flaggedAccount.nameWithHostForced }}</span>+ <div class="account-flagged-handle">{{ abuse.flaggedAccount.nameWithHostForced }}</div></a>++ <my-account-block-badges class="d-inline-block ms-3 align-top" [account]="abuse.flaggedAccount"></my-account-block-badges>+ </div></td>} @else {<td i18n>Account deleted</td>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.tsindex 52a3d7c1b8..30a60fd7d8 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@@ -5,19 +5,20 @@ import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { AbuseState, AbuseStateType, AdminAbuse, ResultList } from '@peertube/peertube-models'import { logger } from '@root-helpers/logger'import debug from 'debug'-import { switchMap } from 'rxjs'+import { map, switchMap } from 'rxjs'import { ActorAvatarComponent } from '../shared-actor-image/actor-avatar.component'import { AdvancedFilterDef } from '../shared-forms/advanced-input-filter.component'import { GlobalIconComponent } from '../shared-icons/global-icon.component'import { Account } from '../shared-main/account/account.model'import { Actor } from '../shared-main/account/actor.model'-import { ActionDropdownComponent, DropdownAction } from '../shared-main/buttons/action-dropdown.component'import { buildDropdownSimpleAndBulkActions } from '../shared-main/buttons/action-dropdown-helpers'+import { ActionDropdownComponent, DropdownAction } from '../shared-main/buttons/action-dropdown.component'import { PTDatePipe } from '../shared-main/common/date.pipe'import { NumberFormatterPipe } from '../shared-main/common/number-formatter.pipe'import { Video } from '../shared-main/video/video.model'import { VideoService } from '../shared-main/video/video.service'import { AbuseService } from '../shared-moderation/abuse.service'+import { AccountBlockBadgesComponent } from '../shared-moderation/account-block-badges.component'import { BlocklistService } from '../shared-moderation/blocklist.service'import { VideoBlockService } from '../shared-moderation/video-block.service'import { TableColumnInfo, TableComponent } from '../shared-tables/table.component'@@ -66,7 +67,8 @@ type DropdownActionForBuilder<T, D = never> =AbuseMessageModalComponent,PTDatePipe,TableComponent,- NumberFormatterPipe+ NumberFormatterPipe,+ AccountBlockBadgesComponent]})export class AbuseListTableComponent implements OnInit, OnDestroy {@@ -277,45 +279,66 @@ export class AbuseListTableComponent implements OnInit, OnDestroy {? this.abuseService.listAdminAbuses(options): this.abuseService.listUserAbuses(options)- return observable.pipe(switchMap(async (resultList: ResultList<ProcessedAbuse>) => {- const abuses: ProcessedAbuse[] = []+ return observable.pipe(+ switchMap(async (resultList: ResultList<ProcessedAbuse>) => {+ const abuses: ProcessedAbuse[] = []- for (const abuse of resultList.data) {- abuse.reasonHtml = await this.toHtml(abuse.reason)+ for (const abuse of resultList.data) {+ abuse.reasonHtml = await this.toHtml(abuse.reason)- if (abuse.moderationComment) {- abuse.moderationCommentHtml = await this.toHtml(abuse.moderationComment)- }+ if (abuse.moderationComment) {+ abuse.moderationCommentHtml = await this.toHtml(abuse.moderationComment)+ }- if (abuse.video) {- if (abuse.video.channel?.ownerAccount) {- abuse.video.channel.ownerAccount = new Account(abuse.video.channel.ownerAccount)+ if (abuse.video) {+ if (abuse.video.channel?.ownerAccount) {+ abuse.video.channel.ownerAccount = new Account(abuse.video.channel.ownerAccount)+ }}- }- if (abuse.comment) {- if (abuse.comment.deleted) {- abuse.commentHTML = $localize`Deleted comment`- } else {- abuse.commentHTML = await this.markdownRenderer.textMarkdownToHTML({ markdown: abuse.comment.text, withHtml: true })+ if (abuse.comment) {+ if (abuse.comment.deleted) {+ abuse.commentHTML = $localize`Deleted comment`+ } else {+ abuse.commentHTML = await this.markdownRenderer.textMarkdownToHTML({ markdown: abuse.comment.text, withHtml: true })+ }}- }- if (abuse.reporterAccount) {- abuse.reporterAccount = new Account(abuse.reporterAccount)- }+ if (abuse.reporterAccount) {+ abuse.reporterAccount = new Account(abuse.reporterAccount)+ }- if (abuse.flaggedAccount) {- abuse.flaggedAccount = new Account(abuse.flaggedAccount)- }+ if (abuse.flaggedAccount) {+ abuse.flaggedAccount = new Account(abuse.flaggedAccount)+ }- if (abuse.updatedAt === abuse.createdAt) delete abuse.updatedAt+ if (abuse.updatedAt === abuse.createdAt) delete abuse.updatedAt- abuses.push(abuse)- }+ abuses.push(abuse)+ }- return { total: resultList.total, data: abuses }- }))+ return { total: resultList.total, data: abuses }+ }),+ switchMap(({ data, total }) => {+ const accounts = data.map(abuse => abuse.reporterAccount)+ .concat(data.map(abuse => abuse.flaggedAccount))+ .filter((account): account is Account => !!account)++ const handlesSet = new Set(accounts.map(account => account.nameWithHostForced))+ const hostsSet = new Set(accounts.map(account => account.host).filter(host => !!host))++ return this.blocklistService.getStatus({ accounts: Array.from(handlesSet), hosts: Array.from(hostsSet) }).pipe(+ map(blockStatus => {+ for (const account of accounts) {+ account.mutedByInstance = blockStatus.accounts[account.nameWithHostForced].blockedByServer+ account.mutedServerByInstance = blockStatus.hosts[account.host].blockedByServer+ }++ return { total, data }+ })+ )+ })+ )}private buildInternalActions (): DropdownActionForBuilder<ProcessedAbuse>[] {diff --git a/client/src/app/shared/shared-moderation/account-block-badges.component.html b/client/src/app/shared/shared-moderation/account-block-badges.component.htmlindex 5fab80048a..c4ed017d59 100644--- a/client/src/app/shared/shared-moderation/account-block-badges.component.html+++ b/client/src/app/shared/shared-moderation/account-block-badges.component.html@@ -3,13 +3,13 @@}@if (account().mutedServerByUser) {- <span class="pt-badge badge-danger" i18n>Instance muted</span>+ <span class="pt-badge badge-danger" i18n>Platform muted</span>}@if (account().mutedByInstance) {- <span class="pt-badge badge-danger" i18n>Muted by your instance</span>+ <span class="pt-badge badge-danger" i18n>Muted by your platform</span>}@if (account().mutedServerByInstance) {- <span class="pt-badge badge-danger" i18n>Instance muted by your instance</span>+ <span class="pt-badge badge-danger" i18n>Platform muted by your platform</span>}diff --git a/client/src/app/shared/shared-moderation/moderation.scss b/client/src/app/shared/shared-moderation/moderation.scssindex 15078dd805..2c3bd462de 100644--- a/client/src/app/shared/shared-moderation/moderation.scss+++ b/client/src/app/shared/shared-moderation/moderation.scss@@ -52,11 +52,6 @@}}-.table-account-link {- display: flex;- flex-direction: column;-}-my-abuse-details {width: 100%;}diff --git a/server/core/middlewares/validators/blocklist.ts b/server/core/middlewares/validators/blocklist.tsindex 1c92255be0..274331a36f 100644--- a/server/core/middlewares/validators/blocklist.ts+++ b/server/core/middlewares/validators/blocklist.ts@@ -25,7 +25,7 @@ const blockAccountValidator = [if (user.Account.id === accountToBlock.id) {res.fail({status: HttpStatusCode.CONFLICT_409,- message: 'You cannot block yourself.'+ message: req.t('You cannot block yourself.')})return}@@ -78,7 +78,7 @@ const blockServerValidator = [if (host === WEBSERVER.HOST) {return res.fail({status: HttpStatusCode.CONFLICT_409,- message: 'You cannot block your own server.'+ message: req.t('You cannot block your own server.')})}