Skip to content

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

Add mute features to videos list

Chocobozzz4ca3d9ecdaab
diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.html
index 864381e6d1..438cad3c16 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.html
+++ b/client/src/app/+admin/overview/videos/video-list.component.html
@@ -14,6 +14,7 @@
searchInput="true"
[inputFilters]="inputFilters"
[defaultInputFilterValues]="defaultInputFilterValues"
+ (dataLoaded)="onDataLoaded()"
>
<ng-template #totalTitle let-totalRecords>
@@ -22,7 +23,10 @@
<ng-template #tableCells let-video>
<td>
- <my-video-cell [video]="video" size="small"></my-video-cell>
+ <my-video-cell
+ [video]="video" [accountBlockBadges]="accountBlocklist.get(video.account.id)"
+ accountBlockBadgesPlatformOnly="true" size="small"
+ ></my-video-cell>
</td>
<td>
@@ -41,13 +45,6 @@
<span [class]="getVideoStateBadgeClass(video.state.id)">{{ video.state.label }}</span>
}
- @if (isAccountBlocked(video)) {
- <span class="pt-badge badge-red" i18n>Account muted</span>
- }
- @if (isServerBlocked(video)) {
- <span class="pt-badge badge-red" i18n>Server muted</span>
- }
-
@if (isVideoBlocked(video)) {
<span class="pt-badge badge-red" i18n>Blocked</span>
}
@@ -93,8 +90,10 @@
<ng-template #actionCell let-video>
<my-video-actions-dropdown
- placement="bottom auto" buttonIcon="more-horizontal" buttonStyled="true" [video]="video" [displayOptions]="videoActionsOptions"
+ placement="bottom auto" buttonIcon="more-horizontal" buttonStyled="true" [video]="video"
+ [displayOptions]="videoActionsOptions" [muteStatus]="accountBlocklist.get(video.account.id)"
(videoRemoved)="table.loadData()" (videoFilesRemoved)="table.loadData()" (transcodingCreated)="table.loadData()"
+ (muted)="loadBlockStatus()" (unmuted)="loadBlockStatus()"
></my-video-actions-dropdown>
</ng-template>
diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts
index 7f6506946e..35e9cbebac 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.ts
+++ b/client/src/app/+admin/overview/videos/video-list.component.ts
@@ -8,6 +8,8 @@ import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'
import { VideoFileTokenService } from '@app/shared/shared-main/video/video-file-token.service'
import { Video } from '@app/shared/shared-main/video/video.model'
import { VideoService } from '@app/shared/shared-main/video/video.service'
+import { AccountBlockBadgeInput } from '@app/shared/shared-moderation/account-block-badges.component'
+import { BlocklistService } from '@app/shared/shared-moderation/blocklist.service'
import { VideoBlockComponent } from '@app/shared/shared-moderation/video-block.component'
import { VideoBlockService } from '@app/shared/shared-moderation/video-block.service'
import { PrivacyBadgeComponent } from '@app/shared/shared-video/privacy-badge.component'
@@ -76,6 +78,7 @@ export class VideoListComponent implements OnInit {
private videoCaptionService = inject(VideoCaptionService)
private server = inject(ServerService)
private videoFileTokenService = inject(VideoFileTokenService)
+ private blocklistService = inject(BlocklistService)
readonly videoBlockModal = viewChild<VideoBlockComponent>('videoBlockModal')
readonly table = viewChild<TableComponent<Video, DataLoaderParameter, ColumnName>>('table')
@@ -93,7 +96,8 @@ export class VideoListComponent implements OnInit {
delete: true,
report: false,
duplicate: true,
- mute: true,
+ muteByUser: false,
+ muteByServer: true,
liveInfo: false,
removeFiles: true,
transcoding: true,
@@ -107,6 +111,9 @@ export class VideoListComponent implements OnInit {
{ id: 'publishedAt', label: $localize`Published`, sortable: true }
]
+ // Key is account id
+ accountBlocklist = new Map<number, AccountBlockBadgeInput>()
+
private videoFileTokens: { [videoId: number]: string } = {}
dataLoader: typeof this._dataLoader
@@ -281,14 +288,6 @@ export class VideoListComponent implements OnInit {
return video.state.id !== VideoState.LIVE_ENDED && video.state.id !== VideoState.PUBLISHED
}
- isAccountBlocked (video: Video) {
- return video.blockedOwner
- }
-
- isServerBlocked (video: Video) {
- return video.blockedServer
- }
-
isVideoBlocked (video: Video) {
return video.blacklisted
}
@@ -394,6 +393,49 @@ export class VideoListComponent implements OnInit {
// ---------------------------------------------------------------------------
+ onDataLoaded () {
+ this.loadBlockStatus()
+ }
+
+ loadBlockStatus () {
+ const videos = this.table().data
+
+ const accounts = this.getUniqueAccounts(videos)
+ const hosts = this.getUniqueHosts(videos)
+
+ this.blocklistService.getStatus({ accounts: accounts.map(a => a.name + '@' + a.host), hosts })
+ .subscribe(status => {
+ this.accountBlocklist = new Map()
+
+ for (const a of accounts) {
+ const handle = a.name + '@' + a.host
+
+ this.accountBlocklist.set(a.id, {
+ mutedByInstance: status.accounts[handle].blockedByServer,
+ mutedServerByInstance: status.hosts[a.host].blockedByServer
+ })
+ }
+ })
+ }
+
+ private getUniqueAccounts (videos: Video[]) {
+ const accountsDone = new Set<number>()
+
+ return videos
+ .map(a => {
+ if (!a.account || accountsDone.has(a.account.id)) return null
+
+ accountsDone.add(a.account.id)
+ return a.account
+ }).filter(a => !!a)
+ }
+
+ private getUniqueHosts (videos: Video[]) {
+ return Array.from(new Set(videos.map(c => c.account.host)))
+ }
+
+ // ---------------------------------------------------------------------------
+
private _dataLoader (
options: DataLoaderOptionsBase & Partial<Parameters<VideoAdminService['listAdminVideos']>[0]> & {
state: VideoStateType | string
diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.ts
index 6aae254dd9..4574cc706c 100644
--- a/client/src/app/+my-library/my-videos/my-videos.component.ts
+++ b/client/src/app/+my-library/my-videos/my-videos.component.ts
@@ -93,7 +93,8 @@ export class MyVideosComponent implements OnInit, OnDestroy {
delete: true,
report: false,
duplicate: false,
- mute: false,
+ muteByUser: false,
+ muteByServer: false,
liveInfo: true,
removeFiles: false,
transcoding: false
diff --git a/client/src/app/+video-watch/shared/action-buttons/action-buttons.component.ts b/client/src/app/+video-watch/shared/action-buttons/action-buttons.component.ts
index 9163d5e73a..dec8c47992 100644
--- a/client/src/app/+video-watch/shared/action-buttons/action-buttons.component.ts
+++ b/client/src/app/+video-watch/shared/action-buttons/action-buttons.component.ts
@@ -70,7 +70,8 @@ export class ActionButtonsComponent implements OnChanges {
delete: true,
report: true,
duplicate: true,
- mute: true,
+ muteByUser: true,
+ muteByServer: true,
liveInfo: true,
generateTranscription: true,
transcriptionWidget: true,
diff --git a/client/src/app/+video-watch/shared/recommendations/recommended-videos.component.html b/client/src/app/+video-watch/shared/recommendations/recommended-videos.component.html
index 2f9cb6c8d0..ac9c51f368 100644
--- a/client/src/app/+video-watch/shared/recommendations/recommended-videos.component.html
+++ b/client/src/app/+video-watch/shared/recommendations/recommended-videos.component.html
@@ -24,7 +24,7 @@
}
<my-video-miniature
[displayOptions]="displayOptions" [video]="video" [user]="user" [displayAsRow]="displayAsRow()"
- (videoBlocked)="onVideoRemoved()" (videoRemoved)="onVideoRemoved()" (videoAccountMuted)="onVideoRemoved()"
+ (videoBlocked)="onVideoRemoved()" (videoRemoved)="onVideoRemoved()" (muted)="onVideoRemoved()"
actorImageSize="32" thumbnailSizes="201px"
>
</my-video-miniature>
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts
index 87ebe9f765..c708a4b39a 100644
--- a/client/src/app/shared/shared-main/video/video.model.ts
+++ b/client/src/app/shared/shared-main/video/video.model.ts
@@ -90,8 +90,8 @@ export class Video implements VideoServerModel {
blacklisted?: boolean
blacklistedReason?: string
- blockedOwner?: boolean
- blockedServer?: boolean
+ blockedOwner?: never
+ blockedServer?: never
account: {
id: number
@@ -207,9 +207,6 @@ export class Video implements VideoServerModel {
this.blacklisted = hash.blacklisted
this.blacklistedReason = hash.blacklistedReason
- this.blockedOwner = hash.blockedOwner
- this.blockedServer = hash.blockedServer
-
this.streamingPlaylists = hash.streamingPlaylists
this.files = hash.files
diff --git a/client/src/app/shared/shared-moderation/account-block-badges.component.ts b/client/src/app/shared/shared-moderation/account-block-badges.component.ts
index a1fc86f525..5e64005be0 100644
--- a/client/src/app/shared/shared-moderation/account-block-badges.component.ts
+++ b/client/src/app/shared/shared-moderation/account-block-badges.component.ts
@@ -1,6 +1,10 @@
import { booleanAttribute, Component, input } from '@angular/core'
import { Account } from '../shared-main/account/account.model'
+export type AccountBlockBadgeInput = Partial<
+ Pick<Account, 'mutedByUser' | 'mutedServerByUser' | 'mutedByInstance' | 'mutedServerByInstance'>
+>
+
@Component({
selector: 'my-account-block-badges',
styleUrls: [ './account-block-badges.component.scss' ],
@@ -8,9 +12,7 @@ import { Account } from '../shared-main/account/account.model'
imports: []
})
export class AccountBlockBadgesComponent {
- readonly account = input.required<
- Partial<Pick<Account, 'mutedByUser' | 'mutedServerByUser' | 'mutedByInstance' | 'mutedServerByInstance'>>
- >()
+ readonly account = input.required<AccountBlockBadgeInput>()
readonly platformOnly = input(false, { transform: booleanAttribute })
}
diff --git a/client/src/app/shared/shared-moderation/blocklist.service.ts b/client/src/app/shared/shared-moderation/blocklist.service.ts
index a307ea9040..10ea22fbf7 100644
--- a/client/src/app/shared/shared-moderation/blocklist.service.ts
+++ b/client/src/app/shared/shared-moderation/blocklist.service.ts
@@ -1,13 +1,15 @@
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable, inject } from '@angular/core'
-import { RestExtractor, RestPagination, RestService } from '@app/core'
+import { AuthUser, Notifier, RestExtractor, RestPagination, RestService } from '@app/core'
+import { formatICU } from '@app/helpers'
import { arrayify } from '@peertube/peertube-core-utils'
-import { AccountBlock as AccountBlockServer, BlockStatus, ResultList, ServerBlock } from '@peertube/peertube-models'
+import { AccountBlock as AccountBlockServer, BlockStatus, ResultList, ServerBlock, UserRight } from '@peertube/peertube-models'
import { SortMeta } from 'primeng/api'
import { from } from 'rxjs'
-import { catchError, concatMap, map, toArray } from 'rxjs/operators'
+import { catchError, concatMap, map, tap, toArray } from 'rxjs/operators'
import { environment } from '../../../environments/environment'
import { Account } from '../shared-main/account/account.model'
+import { Actor } from '../shared-main/account/actor.model'
import { AccountBlock } from './account-block.model'
export enum BlocklistComponentType {
@@ -20,12 +22,31 @@ export class BlocklistService {
private authHttp = inject(HttpClient)
private restExtractor = inject(RestExtractor)
private restService = inject(RestService)
+ private notifier = inject(Notifier)
static BASE_BLOCKLIST_URL = environment.apiUrl + '/api/v1/blocklist'
static BASE_USER_BLOCKLIST_URL = environment.apiUrl + '/api/v1/users/me/blocklist'
static BASE_SERVER_BLOCKLIST_URL = environment.apiUrl + '/api/v1/server/blocklist'
- /** ********************* Blocklist status ***********************/
+ canMuteAccountByAccount (user: AuthUser, account: Pick<Account, 'id'>) {
+ return user && account && user.account.id !== account.id
+ }
+
+ canMutePlatformByAccount (user: AuthUser, account: Pick<Account, 'host'>) {
+ return user && account && !Actor.IS_LOCAL(account.host)
+ }
+
+ canMuteAccountByInstance (user: AuthUser, account: Pick<Account, 'id'>) {
+ return user && account && user.account.id !== account.id && user.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
+ }
+
+ canMutePlatformByInstance (user: AuthUser, account: Pick<Account, 'host'>) {
+ return user && account && !Actor.IS_LOCAL(account.host) && user.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
+ }
+
+ // ---------------------------------------------------------------------------
+ // Blocklist status
+ // ---------------------------------------------------------------------------
getStatus (options: {
accounts?: string[]
@@ -42,7 +63,9 @@ export class BlocklistService {
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
- /** ********************* User -> Account blocklist ***********************/
+ // ---------------------------------------------------------------------------
+ // User -> Account blocklist
+ // ---------------------------------------------------------------------------
getUserAccountBlocklist (options: { pagination: RestPagination, sort: SortMeta, search?: string }) {
const { pagination, sort, search } = options
@@ -73,7 +96,9 @@ export class BlocklistService {
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
- /** ********************* User -> Server blocklist ***********************/
+ // ---------------------------------------------------------------------------
+ // User -> Server blocklist
+ // ---------------------------------------------------------------------------
getUserServerBlocklist (options: { pagination: RestPagination, sort: SortMeta, search?: string }) {
const { pagination, sort, search } = options
@@ -101,7 +126,9 @@ export class BlocklistService {
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
- /** ********************* Instance -> Account blocklist ***********************/
+ // ---------------------------------------------------------------------------
+ // Instance -> Account blocklist
+ // ---------------------------------------------------------------------------
getInstanceAccountBlocklist (options: { pagination: RestPagination, sort: SortMeta, search?: string }) {
const { pagination, sort, search } = options
@@ -118,6 +145,8 @@ export class BlocklistService {
)
}
+ // ---------------------------------------------------------------------------
+
blockAccountByInstance (accountsArg: Pick<Account, 'nameWithHost'> | Pick<Account, 'nameWithHost'>[]) {
const accounts = arrayify(accountsArg)
@@ -129,6 +158,24 @@ export class BlocklistService {
)
}
+ blockAccountByInstanceAndNotify (accountsArg: Pick<Account, 'nameWithHost'> | Pick<Account, 'nameWithHost'>[]) {
+ const accounts = arrayify(accountsArg)
+
+ return this.blockAccountByInstance(accounts)
+ .pipe(
+ tap(() => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Account muted} other {{count} accounts muted}}`,
+ { count: accounts.length }
+ )
+ )
+ })
+ )
+ }
+
+ // ---------------------------------------------------------------------------
+
unblockAccountByInstance (accountsArg: Pick<Account, 'nameWithHost'> | Pick<Account, 'nameWithHost'>[]) {
const accounts = arrayify(accountsArg)
@@ -140,7 +187,25 @@ export class BlocklistService {
)
}
- /** ********************* Instance -> Server blocklist ***********************/
+ unblockAccountByInstanceAndNotify (accountsArg: Pick<Account, 'nameWithHost'> | Pick<Account, 'nameWithHost'>[]) {
+ const accounts = arrayify(accountsArg)
+
+ return this.unblockAccountByInstance(accounts)
+ .pipe(
+ tap(() => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Account unmuted} other {{count} accounts unmuted}}`,
+ { count: accounts.length }
+ )
+ )
+ })
+ )
+ }
+
+ // ---------------------------------------------------------------------------
+ // Instance -> Server blocklist
+ // ---------------------------------------------------------------------------
getInstanceServerBlocklist (options: { pagination: RestPagination, sort: SortMeta, search?: string }) {
const { pagination, sort, search } = options
@@ -154,6 +219,8 @@ export class BlocklistService {
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
+ // ---------------------------------------------------------------------------
+
blockServerByInstance (hostsArg: string | string[]) {
const hosts = arrayify(hostsArg)
@@ -165,6 +232,24 @@ export class BlocklistService {
)
}
+ blockServerByInstanceAndNotify (hostsArg: string | string[]) {
+ const hosts = arrayify(hostsArg)
+
+ return this.blockServerByInstance(hosts)
+ .pipe(
+ tap(() => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Server muted} other {{count} servers muted}}`,
+ { count: hosts.length }
+ )
+ )
+ })
+ )
+ }
+
+ // ---------------------------------------------------------------------------
+
unblockServerByInstance (hostsArg: string | string[]) {
const hosts = arrayify(hostsArg)
@@ -176,6 +261,24 @@ export class BlocklistService {
)
}
+ unblockServerByInstanceAndNotify (hostsArg: string | string[]) {
+ const hosts = arrayify(hostsArg)
+
+ return this.unblockServerByInstance(hosts)
+ .pipe(
+ tap(() => {
+ this.notifier.success(
+ formatICU(
+ $localize`{count, plural, =1 {Server unmuted} other {{count} servers unmuted}}`,
+ { count: hosts.length }
+ )
+ )
+ })
+ )
+ }
+
+ // ---------------------------------------------------------------------------
+
private formatAccountBlock (accountBlock: AccountBlockServer) {
return new AccountBlock(accountBlock)
}
diff --git a/client/src/app/shared/shared-tables/video-cell.component.html b/client/src/app/shared/shared-tables/video-cell.component.html
index b0d9c3fc10..1e3c27c5b5 100644
--- a/client/src/app/shared/shared-tables/video-cell.component.html
+++ b/client/src/app/shared/shared-tables/video-cell.component.html
@@ -29,6 +29,10 @@
}
}
</a>
+
+ @if (accountBlockBadges()) {
+ <my-account-block-badges class="ms-2" [account]="accountBlockBadges()" [platformOnly]="accountBlockBadgesPlatformOnly()"></my-account-block-badges>
+ }
}
</div>
}
diff --git a/client/src/app/shared/shared-tables/video-cell.component.ts b/client/src/app/shared/shared-tables/video-cell.component.ts
index fdadf65835..74252d9db4 100644
--- a/client/src/app/shared/shared-tables/video-cell.component.ts
+++ b/client/src/app/shared/shared-tables/video-cell.component.ts
@@ -5,6 +5,7 @@ import { AuthService, ScreenService } from '@app/core'
import { CollaboratorStateComponent } from '../shared-main/channel/collaborator-state.component'
import { VideoChannel } from '../shared-main/channel/video-channel.model'
import { Video } from '../shared-main/video/video.model'
+import { AccountBlockBadgeInput, AccountBlockBadgesComponent } from '../shared-moderation/account-block-badges.component'
import { VideoThumbnailComponent } from '../shared-thumbnail/video-thumbnail.component'
@Component({
@@ -16,7 +17,8 @@ import { VideoThumbnailComponent } from '../shared-thumbnail/video-thumbnail.com
CommonModule,
RouterLink,
VideoThumbnailComponent,
- CollaboratorStateComponent
+ CollaboratorStateComponent,
+ AccountBlockBadgesComponent
]
})
export class VideoCellComponent implements OnInit {
@@ -28,6 +30,8 @@ export class VideoCellComponent implements OnInit {
readonly thumbnail = input(true, { transform: booleanAttribute })
readonly title = input(true, { transform: booleanAttribute })
readonly displayEditorInfo = input(false, { transform: booleanAttribute })
+ readonly accountBlockBadges = input<AccountBlockBadgeInput>()
+ readonly accountBlockBadgesPlatformOnly = input(false, { transform: booleanAttribute })
ellipsis: boolean
diff --git a/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.ts b/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.ts
index 204c9ccbbc..6e452cfa6c 100644
--- a/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.ts
+++ b/client/src/app/shared/shared-video-comment/video-comment-list-admin-owner.component.ts
@@ -161,7 +161,7 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
return this.mode() === 'admin' &&
comment.account &&
!comment.account.mutedByInstance &&
- this.user.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
+ this.blocklist.canMuteAccountByInstance(this.user, comment.account)
},
enableBulk: true
@@ -178,7 +178,7 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
return this.mode() === 'admin' &&
comment.account &&
comment.account.mutedByInstance &&
- this.user.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)
+ this.blocklist.canMuteAccountByInstance(this.user, comment.account)
},
enableBulk: true
},
@@ -194,7 +194,7 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
return this.mode() === 'admin' &&
comment.account &&
!comment.account.mutedServerByInstance &&
- this.user.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
+ this.blocklist.canMutePlatformByInstance(this.user, comment.account)
},
enableBulk: true
},
@@ -209,9 +209,8 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
isDisplayed: comment => {
return this.mode() === 'admin' &&
comment.account &&
- !Actor.IS_LOCAL(comment.account.host) &&
comment.account.mutedServerByInstance &&
- this.user.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)
+ this.blocklist.canMutePlatformByInstance(this.user, comment.account)
},
enableBulk: true
}
@@ -251,8 +250,8 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
},
{
type: 'checkbox',
- key: 'includeMuted',
- label: $localize`Include comments from muted accounts`
+ key: 'excludeMuted',
+ label: $localize`Exclude comments from muted accounts`
},
{
@@ -341,8 +340,10 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
}
private loadBlockStatus () {
- const accounts = this.table().data.map(c => c.account)
- const hosts = [ ...new Set(accounts.map(a => a.host)) ]
+ const comments = this.table().data
+
+ const accounts = this.getUniqueAccounts(comments)
+ const hosts = this.getUniqueHosts(comments)
this.blocklist.getStatus({ accounts: accounts.map(a => a.nameWithHostForced), hosts })
.subscribe(status => {
@@ -423,36 +424,17 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
})
}
- private getUniqueAccounts (comments: VideoCommentForAdminOrUser[]) {
- const accountsDone = new Set<number>()
-
- return comments
- .map(a => {
- if (!a.account || accountsDone.has(a.account.id)) return null
-
- accountsDone.add(a.account.id)
- return a.account
- }).filter(a => !!a)
- }
-
- private getUniqueHosts (comments: VideoCommentForAdminOrUser[]) {
- return Array.from(new Set(comments.map(c => c.account?.host).filter(h => !!h)))
- }
+ // ---------------------------------------------------------------------------
+ // Block/unblock accounts and servers
+ // ---------------------------------------------------------------------------
private muteAccount (comments: VideoCommentForAdminOrUser[]) {
const accounts = this.getUniqueAccounts(comments)
- .map(account => ({ nameWithHost: Actor.CREATE_BY_STRING(account.name, account.host) }))
+ .map(account => ({ nameWithHost: account.name + '@' + account.host }))
- this.blocklist.blockAccountByInstance(accounts)
+ this.blocklist.blockAccountByInstanceAndNotify(accounts)
.subscribe({
next: () => {
- this.notifier.success(
- formatICU(
- $localize`{count, plural, =1 {Account muted.} other {{count} accounts muted.}}`,
- { count: accounts.length }
- )
- )
-
this.loadBlockStatus()
},
@@ -462,18 +444,11 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
private unmuteAccount (comments: VideoCommentForAdminOrUser[]) {
const accounts = this.getUniqueAccounts(comments)
- .map(account => ({ nameWithHost: Actor.CREATE_BY_STRING(account.name, account.host) }))
+ .map(account => ({ nameWithHost: account.name + '@' + account.host }))
- this.blocklist.unblockAccountByInstance(accounts)
+ this.blocklist.unblockAccountByInstanceAndNotify(accounts)
.subscribe({
next: () => {
- this.notifier.success(
- formatICU(
- $localize`{count, plural, =1 {Account unmuted.} other {{count} accounts unmuted.}}`,
- { count: accounts.length }
- )
- )
-
this.loadBlockStatus()
},
@@ -484,16 +459,9 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
private muteServer (comments: VideoCommentForAdminOrUser[]) {
const hosts = this.getUniqueHosts(comments)
- this.blocklist.blockServerByInstance(hosts)
+ this.blocklist.blockServerByInstanceAndNotify(hosts)
.subscribe({
next: () => {
- this.notifier.success(
- formatICU(
- $localize`{count, plural, =1 {Platform muted.} other {{count} platforms muted.}}`,
- { count: hosts.length }
- )
- )
-
this.loadBlockStatus()
},
@@ -504,20 +472,29 @@ export class VideoCommentListAdminOwnerComponent implements OnInit, OnDestroy {
private unmuteServer (comments: VideoCommentForAdminOrUser[]) {
const hosts = this.getUniqueHosts(comments)
- this.blocklist.unblockServerByInstance(hosts)
+ this.blocklist.unblockServerByInstanceAndNotify(hosts)
.subscribe({
next: () => {
- this.notifier.success(
- formatICU(
- $localize`{count, plural, =1 {Platform unmuted.} other {{count} platforms unmuted.}}`,
- { count: hosts.length }
- )
- )
-
this.loadBlockStatus()
},
error: err => this.notifier.handleError(err)
})
}
+
+ private getUniqueAccounts (comments: VideoCommentForAdminOrUser[]) {
+ const accountsDone = new Set<number>()
+
+ return comments
+ .map(a => {
+ if (!a.account || accountsDone.has(a.account.id)) return null
+
+ accountsDone.add(a.account.id)
+ return a.account
+ }).filter(a => !!a)
+ }
+
+ private getUniqueHosts (comments: VideoCommentForAdminOrUser[]) {
+ return Array.from(new Set(comments.map(c => c.account?.host).filter(h => !!h)))
+ }
}
diff --git a/client/src/app/shared/shared-video-comment/video-comment.service.ts b/client/src/app/shared/shared-video-comment/video-comment.service.ts
index c5175863cb..0d3f36148e 100644
--- a/client/src/app/shared/shared-video-comment/video-comment.service.ts
+++ b/client/src/app/shared/shared-video-comment/video-comment.service.ts
@@ -102,10 +102,10 @@ export class VideoCommentService {
options: Parameters<VideoCommentService['buildAdminVideoCommentsParams']>[0] & {
isLocal?: boolean
onLocalVideo?: boolean
- includeMuted?: boolean
+ excludeMuted?: boolean
}
): Observable<ResultList<VideoCommentForAdminOrUser>> {
- const { isLocal, onLocalVideo, includeMuted } = options
+ const { isLocal, onLocalVideo, excludeMuted } = options
const url = VideoCommentService.BASE_VIDEO_URL + 'comments'
@@ -119,8 +119,11 @@ export class VideoCommentService {
params = params.set('onLocalVideo', '' + onLocalVideo)
}
- if (includeMuted !== undefined) {
- params = params.set('includeMuted', '' + includeMuted)
+ // Include muted by default
+ if (excludeMuted === true) {
+ params = params.set('includeMuted', 'false')
+ } else {
+ params = params.set('includeMuted', 'true')
}
return this.authHttp.get<ResultList<VideoCommentForAdminOrUser>>(url, { params })
diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.html b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.html
index 9236e641f8..65045cdfee 100644
--- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.html
+++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.html
@@ -14,7 +14,11 @@
<span class="anchor" ngbDropdownAnchor></span>
<div ngbDropdownMenu>
@defer (when dropdownOpened) {
- <my-video-add-to-playlist #playlistAdd [video]="video()" (videoExistsInPlaylistChange)="videoExistsInPlaylistChange.emit()"></my-video-add-to-playlist>
+ <my-video-add-to-playlist
+ #playlistAdd
+ [video]="video()"
+ (videoExistsInPlaylistChange)="videoExistsInPlaylistChange.emit()"
+ ></my-video-add-to-playlist>
}
</div>
</div>
diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
index 2ff657c169..f01f9e2081 100644
--- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts
@@ -15,6 +15,7 @@ import { RedundancyService } from '../shared-main/video/redundancy.service'
import { VideoDetails } from '../shared-main/video/video-details.model'
import { Video } from '../shared-main/video/video.model'
import { VideoService } from '../shared-main/video/video.service'
+import { AccountBlockBadgeInput } from '../shared-moderation/account-block-badges.component'
import { BlocklistService } from '../shared-moderation/blocklist.service'
import { VideoReportComponent } from '../shared-moderation/report-modals'
import { VideoBlockComponent } from '../shared-moderation/video-block.component'
@@ -30,7 +31,8 @@ export type VideoActionsDisplayType = {
delete?: boolean
report?: boolean
duplicate?: boolean
- mute?: boolean
+ muteByUser?: boolean
+ muteByServer?: boolean
liveInfo?: boolean
removeFiles?: boolean
transcoding?: boolean
@@ -72,8 +74,9 @@ export class VideoActionsDropdownComponent implements OnChanges {
readonly videoReportModal = viewChild<VideoReportComponent>('videoReportModal')
readonly videoBlockModal = viewChild<VideoBlockComponent>('videoBlockModal')
- readonly video = input<Video | VideoDetails>(undefined)
+ readonly video = input<Video | VideoDetails>()
readonly videoCaptions = input<VideoCaption[]>([])
+ readonly muteStatus = input<AccountBlockBadgeInput>()
readonly displayOptions = input<VideoActionsDisplayType>({
playlist: false,
@@ -83,7 +86,8 @@ export class VideoActionsDropdownComponent implements OnChanges {
delete: true,
report: true,
duplicate: true,
- mute: true,
+ muteByUser: true,
+ muteByServer: true,
liveInfo: false,
removeFiles: false,
transcoding: false,
@@ -108,7 +112,8 @@ export class VideoActionsDropdownComponent implements OnChanges {
readonly videoRemoved = output()
readonly videoUnblocked = output()
readonly videoBlocked = output()
- readonly videoAccountMuted = output()
+ readonly muted = output()
+ readonly unmuted = output()
readonly transcodingCreated = output()
readonly modalOpened = output()
readonly videoExistsInPlaylistChange = output()
@@ -120,8 +125,6 @@ export class VideoActionsDropdownComponent implements OnChanges {
dropdownOpened = false
- private hasMutedAccount = false
-
get user () {
return this.authService.getUser()
}
@@ -256,12 +259,6 @@ export class VideoActionsDropdownComponent implements OnChanges {
return !video.isLive && video.canBeDuplicatedBy(this.user)
}
- isVideoAccountMutable () {
- if (!this.user) return false
-
- return this.video().account.id !== this.user.account.id
- }
-
canRemoveVideoFiles () {
if (!this.user) return false
@@ -335,28 +332,30 @@ export class VideoActionsDropdownComponent implements OnChanges {
})
}
- muteVideoAccount () {
- const params = { nameWithHost: Actor.CREATE_BY_STRING(this.video().account.name, this.video().account.host) }
+ // ---------------------------------------------------------------------------
+
+ muteAccount () {
+ const params = { nameWithHost: this.video().account.name + '@' + this.video().account.host }
this.blocklistService.blockAccountByUser(params)
.subscribe({
next: () => {
this.notifier.success($localize`Account ${params.nameWithHost} muted.`)
- this.hasMutedAccount = true
- this.videoAccountMuted.emit()
+ this.muted.emit()
},
error: err => this.notifier.handleError(err)
})
}
- unmuteVideoAccount () {
- const params = { nameWithHost: Actor.CREATE_BY_STRING(this.video().account.name, this.video().account.host) }
+ unmuteAccount () {
+ const params = { nameWithHost: this.video().account.name + '@' + this.video().account.host }
this.blocklistService.unblockAccountByUser(params)
.subscribe({
next: () => {
- this.hasMutedAccount = false
+ this.unmuted.emit()
+
this.notifier.success($localize`Account ${params.nameWithHost} unmuted.`)
},
@@ -364,6 +363,91 @@ export class VideoActionsDropdownComponent implements OnChanges {
})
}
+ muteServer () {
+ const host = this.video().account.host
+
+ this.blocklistService.blockServerByUser(host)
+ .subscribe({
+ next: () => {
+ this.notifier.success($localize`Server ${host} muted.`)
+ this.muted.emit()
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ unmuteServer () {
+ const host = this.video().account.host
+
+ this.blocklistService.unblockServerByUser(host)
+ .subscribe({
+ next: () => {
+ this.unmuted.emit()
+
+ this.notifier.success($localize`Server ${host} unmuted.`)
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ // ---------------------------------------------------------------------------
+
+ muteAccountByServer () {
+ const params = { nameWithHost: this.video().account.name + '@' + this.video().account.host }
+
+ this.blocklistService.blockAccountByInstanceAndNotify(params)
+ .subscribe({
+ next: () => {
+ this.muted.emit()
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ unmuteAccountByServer () {
+ const params = { nameWithHost: this.video().account.name + '@' + this.video().account.host }
+
+ this.blocklistService.unblockAccountByInstanceAndNotify(params)
+ .subscribe({
+ next: () => {
+ this.unmuted.emit()
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ muteServerByServer () {
+ const host = this.video().account.host
+
+ this.blocklistService.blockServerByInstanceAndNotify(host)
+ .subscribe({
+ next: () => {
+ this.muted.emit()
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ unmuteServerByServer () {
+ const host = this.video().account.host
+
+ this.blocklistService.unblockServerByInstanceAndNotify(host)
+ .subscribe({
+ next: () => {
+ this.unmuted.emit()
+ },
+
+ error: err => this.notifier.handleError(err)
+ })
+ }
+
+ // ---------------------------------------------------------------------------
+
async removeVideoFiles (video: Video, type: 'hls' | 'web-videos') {
const confirmMessage = $localize`Do you really want to remove "${this.video().name}" files?`
@@ -546,19 +630,91 @@ export class VideoActionsDropdownComponent implements OnChanges {
iconName: 'video-lang'
}
],
- [ // actions regarding the account/its server
+ [
{
label: $localize`Mute account`,
- handler: () => this.muteVideoAccount(),
- isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions().mute && this.isVideoAccountMutable(),
+ handler: () => this.muteAccount(),
+ isDisplayed: () =>
+ this.authService.isLoggedIn() &&
+ this.displayOptions().muteByUser &&
+ this.muteStatus()?.mutedByUser === false &&
+ this.blocklistService.canMuteAccountByAccount(this.user, this.video().account),
iconName: 'no'
},
{
label: $localize`Unmute account`,
- handler: () => this.unmuteVideoAccount(),
- isDisplayed: () => {
- return this.authService.isLoggedIn() && this.displayOptions().mute && this.isVideoAccountMutable() && this.hasMutedAccount
- },
+ handler: () => this.unmuteAccount(),
+ isDisplayed: () =>
+ this.authService.isLoggedIn() &&
+ this.displayOptions().muteByUser &&
+ this.muteStatus()?.mutedByUser === true &&
+ this.blocklistService.canMuteAccountByAccount(this.user, this.video().account),
+
+ iconName: 'undo'
+ },
+ {
+ label: $localize`Mute platform`,
+ handler: () => this.muteServer(),
+ isDisplayed: () =>
+ this.authService.isLoggedIn() &&
+ this.displayOptions().muteByUser &&
+ this.muteStatus()?.mutedServerByUser === false &&
+ this.blocklistService.canMutePlatformByAccount(this.user, this.video().account),
+ iconName: 'no'
+ },
+ {
+ label: $localize`Unmute platform`,
+ handler: () => this.unmuteServer(),
+ isDisplayed: () =>
+ this.authService.isLoggedIn() &&
+ this.displayOptions().muteByUser &&
+ this.muteStatus()?.mutedServerByUser === true &&
+ this.blocklistService.canMutePlatformByAccount(this.user, this.video().account),
+
+ iconName: 'undo'
+ }
+ ],
+ [
+ {
+ label: $localize`Mute account by your platform`,
+ handler: () => this.muteAccountByServer(),
+ isDisplayed: () =>
+ this.authService.isLoggedIn() &&
+ this.displayOptions().muteByServer &&
+ this.muteStatus()?.mutedByInstance === false &&
+ this.blocklistService.canMuteAccountByInstance(this.user, this.video().account),
+ iconName: 'no'
+ },
+ {
+ label: $localize`Unmute account by your platform`,
+ handler: () => this.unmuteAccountByServer(),
+ isDisplayed: () =>
+ this.authService.isLoggedIn() &&
+ this.displayOptions().muteByServer &&
+ this.muteStatus()?.mutedByInstance === true &&
+ this.blocklistService.canMuteAccountByInstance(this.user, this.video().account),
+
+ iconName: 'undo'
+ },
+ {
+ label: $localize`Mute platform by your platform`,
+ handler: () => this.muteServerByServer(),
+ isDisplayed: () =>
+ this.authService.isLoggedIn() &&
+ this.displayOptions().muteByServer &&
+ this.muteStatus()?.mutedServerByInstance === false &&
+ this.blocklistService.canMutePlatformByInstance(this.user, this.video().account),
+ iconName: 'no'
+ },
+ {
+ label: $localize`Unmute platform by your platform`,
+ handler: () => this.unmuteServerByServer(),
+ isDisplayed: () =>
+ this.authService.isLoggedIn() &&
+ this.displayOptions().muteByServer &&
+ this.muteStatus()?.mutedServerByInstance === true &&
+ this.blocklistService.canMutePlatformByInstance(this.user, this.video().account),
+
iconName: 'undo'
}
]
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.html b/client/src/app/shared/shared-video-miniature/video-miniature.component.html
index 633614d32c..79bd482f40 100644
--- a/client/src/app/shared/shared-video-miniature/video-miniature.component.html
+++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.html
@@ -105,7 +105,7 @@
(videoRemoved)="onVideoRemoved()"
(videoBlocked)="onVideoBlocked()"
(videoUnblocked)="onVideoUnblocked()"
- (videoAccountMuted)="onVideoAccountMuted()"
+ (muted)="onMuted()"
></my-video-actions-dropdown>
}
</div>
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
index b22d71a10d..3ccdfade35 100644
--- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
@@ -86,7 +86,8 @@ export class VideoMiniatureComponent implements OnInit {
delete: true,
report: true,
duplicate: true,
- mute: true
+ muteByUser: true,
+ muteByServer: true
})
readonly actorImageSize = input(34, { transform: numberAttribute })
@@ -98,7 +99,7 @@ export class VideoMiniatureComponent implements OnInit {
readonly videoBlocked = output()
readonly videoUnblocked = output()
readonly videoRemoved = output()
- readonly videoAccountMuted = output()
+ readonly muted = output()
showActions = false
serverConfig: HTMLServerConfig
@@ -254,8 +255,8 @@ export class VideoMiniatureComponent implements OnInit {
this.videoRemoved.emit()
}
- onVideoAccountMuted () {
- this.videoAccountMuted.emit()
+ onMuted () {
+ this.muted.emit()
}
isUserLoggedIn () {
diff --git a/packages/models/src/videos/video-include.enum.ts b/packages/models/src/videos/video-include.enum.ts
index 267ba93b72..c3fece91d9 100644
--- a/packages/models/src/videos/video-include.enum.ts
+++ b/packages/models/src/videos/video-include.enum.ts
@@ -2,7 +2,7 @@ export const VideoInclude = {
NONE: 0,
NOT_PUBLISHED_STATE: 1 << 0,
BLACKLISTED: 1 << 1,
- BLOCKED_OWNER: 1 << 2,
+ BLOCKED_OWNER: 1 << 2, // Deprecated in PeerTube 8.2
FILES: 1 << 3,
CAPTIONS: 1 << 4,
SOURCE: 1 << 5,
diff --git a/server/core/controllers/api/blocklist.ts b/server/core/controllers/api/blocklist.ts
index 4d2e5c6c31..f045935b09 100644
--- a/server/core/controllers/api/blocklist.ts
+++ b/server/core/controllers/api/blocklist.ts
@@ -68,9 +68,9 @@ async function populateServerBlocklistStatus (options: {
logger.debug('Got server blocklist status.', { serverBlocklistStatus, byAccountIds, hosts })
for (const host of hosts) {
- const block = serverBlocklistStatus.find(b => b.host === host)
+ const blocks = serverBlocklistStatus.filter(b => b.host === host)
- status.hosts[host] = getStatus(block, serverActor, user)
+ status.hosts[host] = getStatus(blocks, serverActor, user)
}
}
@@ -92,15 +92,15 @@ async function populateAccountBlocklistStatus (options: {
for (const account of accounts) {
const sanitizedHandle = handleToNameAndHost(account)
- const block = accountBlocklistStatus.find(b => b.name === sanitizedHandle.name && b.host === sanitizedHandle.host)
+ const blocks = accountBlocklistStatus.filter(b => b.name === sanitizedHandle.name && b.host === sanitizedHandle.host)
- status.accounts[sanitizedHandle.handle] = getStatus(block, serverActor, user)
+ status.accounts[sanitizedHandle.handle] = getStatus(blocks, serverActor, user)
}
}
-function getStatus (block: { accountId: number }, serverActor: MActorAccountId, user?: MUserAccountId) {
+function getStatus (blocks: { accountId: number }[], serverActor: MActorAccountId, user?: MUserAccountId) {
return {
- blockedByServer: !!(block?.accountId === serverActor.Account.id),
- blockedByUser: !!(block && block.accountId === user?.Account.id)
+ blockedByServer: blocks.some(block => block.accountId === serverActor.Account.id),
+ blockedByUser: blocks.some(block => block.accountId === user?.Account.id)
}
}