)
}
- blockAccountByUser (account: Account) {
+ blockAccountByUser (account: Pick<Account, 'nameWithHost'>) {
const body = { accountName: account.nameWithHost }
return this.authHttp.post(BlocklistService.BASE_USER_BLOCKLIST_URL + '/accounts', body)
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
- unblockAccountByUser (account: Account) {
+ unblockAccountByUser (account: Pick<Account, 'nameWithHost'>) {
const path = BlocklistService.BASE_USER_BLOCKLIST_URL + '/accounts/' + account.nameWithHost
return this.authHttp.delete(path)
)
}
- blockAccountByInstance (account: Account) {
+ blockAccountByInstance (account: Pick<Account, 'nameWithHost'>) {
const body = { accountName: account.nameWithHost }
return this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts', body)
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
- unblockAccountByInstance (account: Account) {
+ unblockAccountByInstance (account: Pick<Account, 'nameWithHost'>) {
const path = BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts/' + account.nameWithHost
return this.authHttp.delete(path)
import { Component, EventEmitter, Input, OnChanges, Output, ViewChild } from '@angular/core'
import { AuthService, ConfirmService, Notifier, ScreenService } from '@app/core'
-import { VideoBlockComponent, VideoBlockService, VideoReportComponent } from '@app/shared/shared-moderation'
+import { VideoBlockComponent, VideoBlockService, VideoReportComponent, BlocklistService } from '@app/shared/shared-moderation'
import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap'
import { I18n } from '@ngx-translate/i18n-polyfill'
import { VideoCaption } from '@shared/models'
-import { DropdownAction, DropdownButtonSize, DropdownDirection, RedundancyService, Video, VideoDetails, VideoService } from '../shared-main'
+import { DropdownAction, DropdownButtonSize, DropdownDirection, RedundancyService, Video, VideoDetails, VideoService, Actor } from '../shared-main'
import { VideoAddToPlaylistComponent } from '../shared-video-playlist'
import { VideoDownloadComponent } from './video-download.component'
delete?: boolean
report?: boolean
duplicate?: boolean
+ mute?: boolean
}
@Component({
blacklist: true,
delete: true,
report: true,
- duplicate: true
+ duplicate: true,
+ mute: true
}
@Input() placement = 'left'
@Output() videoRemoved = new EventEmitter()
@Output() videoUnblocked = new EventEmitter()
@Output() videoBlocked = new EventEmitter()
+ @Output() videoAccountMuted = new EventEmitter()
@Output() modalOpened = new EventEmitter()
videoActions: DropdownAction<{ video: Video }>[][] = []
private authService: AuthService,
private notifier: Notifier,
private confirmService: ConfirmService,
+ private blocklistService: BlocklistService,
private videoBlocklistService: VideoBlockService,
private screenService: ScreenService,
private videoService: VideoService,
return this.video.canBeDuplicatedBy(this.user)
}
+ isVideoAccountMutable () {
+ return this.video.account.id !== this.user.account.id
+ }
+
/* Action handlers */
async unblockVideo () {
const res = await this.confirmService.confirm(confirmMessage, this.i18n('Unblock'))
if (res === false) return
- this.videoBlocklistService.unblockVideo(this.video.id).subscribe(
- () => {
- this.notifier.success(this.i18n('Video {{name}} unblocked.', { name: this.video.name }))
+ this.videoBlocklistService.unblockVideo(this.video.id)
+ .subscribe(
+ () => {
+ this.notifier.success(this.i18n('Video {{name}} unblocked.', { name: this.video.name }))
- this.video.blacklisted = false
- this.video.blockedReason = null
+ this.video.blacklisted = false
+ this.video.blockedReason = null
- this.videoUnblocked.emit()
- },
+ this.videoUnblocked.emit()
+ },
- err => this.notifier.error(err.message)
- )
+ err => this.notifier.error(err.message)
+ )
}
async removeVideo () {
duplicateVideo () {
this.redundancyService.addVideoRedundancy(this.video)
- .subscribe(
- () => {
- const message = this.i18n('This video will be duplicated by your instance.')
- this.notifier.success(message)
- },
+ .subscribe(
+ () => {
+ const message = this.i18n('This video will be duplicated by your instance.')
+ this.notifier.success(message)
+ },
- err => this.notifier.error(err.message)
- )
+ err => this.notifier.error(err.message)
+ )
+ }
+
+ muteVideoAccount () {
+ const params = { nameWithHost: Actor.CREATE_BY_STRING(this.video.account.name, this.video.account.host) }
+
+ this.blocklistService.blockAccountByUser(params)
+ .subscribe(
+ () => {
+ this.notifier.success(this.i18n('Account {{nameWithHost}} muted.', params))
+
+ this.videoAccountMuted.emit()
+ },
+
+ err => this.notifier.error(err.message)
+ )
}
onVideoBlocked () {
iconName: 'playlist-add'
}
],
- [
+ [ // actions regarding the video
{
label: this.i18n('Download'),
handler: () => this.showDownloadModal(),
handler: () => this.removeVideo(),
isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.delete && this.isVideoRemovable(),
iconName: 'delete'
- }
- ],
- [
+ },
{
label: this.i18n('Report'),
handler: () => this.showReportModal(),
isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.report,
iconName: 'alert'
}
+ ],
+ [ // actions regarding the account/its server
+ {
+ label: this.i18n('Mute account'),
+ handler: () => this.muteVideoAccount(),
+ isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions.mute && this.isVideoAccountMutable(),
+ iconName: 'no'
+ }
]
]
}