Continue user mute in ban modal PR
This commit is contained in:
parent
5a8de57d57
commit
a282e4d8a0
|
@ -62,10 +62,10 @@
|
||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
<th *ngIf="isSelected('username')" pResizableColumn pSortableColumn="username">{{ getColumn('username').label }} <p-sortIcon field="username"></p-sortIcon></th>
|
<th *ngIf="isSelected('username')" pResizableColumn pSortableColumn="username">{{ getColumn('username').label }} <p-sortIcon field="username"></p-sortIcon></th>
|
||||||
|
<th *ngIf="isSelected('role')" style="width: 120px;" pSortableColumn="role">{{ getColumn('role').label }} <p-sortIcon field="role"></p-sortIcon></th>
|
||||||
<th *ngIf="isSelected('email')">{{ getColumn('email').label }}</th>
|
<th *ngIf="isSelected('email')">{{ getColumn('email').label }}</th>
|
||||||
<th *ngIf="isSelected('quota')" style="width: 160px;" pSortableColumn="videoQuotaUsed">{{ getColumn('quota').label }} <p-sortIcon field="videoQuotaUsed"></p-sortIcon></th>
|
<th *ngIf="isSelected('quota')" style="width: 160px;" pSortableColumn="videoQuotaUsed">{{ getColumn('quota').label }} <p-sortIcon field="videoQuotaUsed"></p-sortIcon></th>
|
||||||
<th *ngIf="isSelected('quotaDaily')" style="width: 160px;">{{ getColumn('quotaDaily').label }}</th>
|
<th *ngIf="isSelected('quotaDaily')" style="width: 160px;">{{ getColumn('quotaDaily').label }}</th>
|
||||||
<th *ngIf="isSelected('role')" style="width: 120px;" pSortableColumn="role">{{ getColumn('role').label }} <p-sortIcon field="role"></p-sortIcon></th>
|
|
||||||
<th *ngIf="isSelected('pluginAuth')" style="width: 140px;" pResizableColumn >{{ getColumn('pluginAuth').label }}</th>
|
<th *ngIf="isSelected('pluginAuth')" style="width: 140px;" pResizableColumn >{{ getColumn('pluginAuth').label }}</th>
|
||||||
<th *ngIf="isSelected('createdAt')" style="width: 150px;" pSortableColumn="createdAt">{{ getColumn('createdAt').label }} <p-sortIcon field="createdAt"></p-sortIcon></th>
|
<th *ngIf="isSelected('createdAt')" style="width: 150px;" pSortableColumn="createdAt">{{ getColumn('createdAt').label }} <p-sortIcon field="createdAt"></p-sortIcon></th>
|
||||||
<th *ngIf="isSelected('lastLoginDate')" style="width: 150px;" pSortableColumn="lastLoginDate">{{ getColumn('lastLoginDate').label }} <p-sortIcon field="lastLoginDate"></p-sortIcon></th>
|
<th *ngIf="isSelected('lastLoginDate')" style="width: 150px;" pSortableColumn="lastLoginDate">{{ getColumn('lastLoginDate').label }} <p-sortIcon field="lastLoginDate"></p-sortIcon></th>
|
||||||
|
@ -84,8 +84,9 @@
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="action-cell">
|
<td class="action-cell">
|
||||||
<my-user-moderation-dropdown *ngIf="!isInSelectionMode()" [user]="user" container="body"
|
<my-user-moderation-dropdown
|
||||||
(userChanged)="onUserChanged()" (userDeleted)="onUserChanged()">
|
*ngIf="!isInSelectionMode()" [user]="user" [account]="user.accountMutedStatus" [displayOptions]="userModerationDisplayOptions"
|
||||||
|
container="body" (userChanged)="onUserChanged()" (userDeleted)="onUserChanged()">
|
||||||
</my-user-moderation-dropdown>
|
</my-user-moderation-dropdown>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
@ -99,6 +100,14 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
<div *ngIf="user.accountMutedStatus.mutedByInstance" class="badges-username badge badge-red" i18n>Muted</div>
|
||||||
|
<div *ngIf="user.blocked" class="badges-username badge badge-red" i18n>Banned</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td *ngIf="isSelected('role')">
|
||||||
|
<span *ngIf="user.blocked" class="badge badge-banned" i18n-title title="The user was banned">{{ user.roleLabel }}</span>
|
||||||
|
<span *ngIf="!user.blocked" class="badge" [ngClass]="getRoleClass(user.role)">{{ user.roleLabel }}</span>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td *ngIf="isSelected('email')" [title]="user.email">
|
<td *ngIf="isSelected('email')" [title]="user.email">
|
||||||
|
@ -138,11 +147,6 @@
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td *ngIf="isSelected('role')">
|
|
||||||
<span *ngIf="user.blocked" class="badge badge-banned" i18n-title title="The user was banned">{{ user.roleLabel }}</span>
|
|
||||||
<span *ngIf="!user.blocked" class="badge" [ngClass]="getRoleClass(user.role)">{{ user.roleLabel }}</span>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<td *ngIf="isSelected('pluginAuth')">
|
<td *ngIf="isSelected('pluginAuth')">
|
||||||
<ng-container *ngIf="user.pluginAuth">{{ user.pluginAuth }}</ng-container>
|
<ng-container *ngIf="user.pluginAuth">{{ user.pluginAuth }}</ng-container>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -23,6 +23,10 @@ tr.banned > td {
|
||||||
font-weight: $font-semibold;
|
font-weight: $font-semibold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.badges-username {
|
||||||
|
margin-left: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
.user-table-primary-text .glyphicon {
|
.user-table-primary-text .glyphicon {
|
||||||
@include margin-left(0.1rem);
|
@include margin-left(0.1rem);
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@ import { SortMeta } from 'primeng/api'
|
||||||
import { Component, OnInit, ViewChild } from '@angular/core'
|
import { Component, OnInit, ViewChild } from '@angular/core'
|
||||||
import { ActivatedRoute, Router } from '@angular/router'
|
import { ActivatedRoute, Router } from '@angular/router'
|
||||||
import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'
|
import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, ServerService } from '@app/core'
|
||||||
|
import { getAPIHost } from '@app/helpers'
|
||||||
import { AdvancedInputFilter } from '@app/shared/shared-forms'
|
import { AdvancedInputFilter } from '@app/shared/shared-forms'
|
||||||
import { DropdownAction } from '@app/shared/shared-main'
|
import { Actor, DropdownAction } from '@app/shared/shared-main'
|
||||||
import { UserBanModalComponent } from '@app/shared/shared-moderation'
|
import { AccountMutedStatus, BlocklistService, UserBanModalComponent, UserModerationDisplayType } from '@app/shared/shared-moderation'
|
||||||
import { UserAdminService } from '@app/shared/shared-users'
|
import { UserAdminService } from '@app/shared/shared-users'
|
||||||
import { User, UserRole } from '@shared/models'
|
import { User, UserRole } from '@shared/models'
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ type UserForList = User & {
|
||||||
export class UserListComponent extends RestTable implements OnInit {
|
export class UserListComponent extends RestTable implements OnInit {
|
||||||
@ViewChild('userBanModal', { static: true }) userBanModal: UserBanModalComponent
|
@ViewChild('userBanModal', { static: true }) userBanModal: UserBanModalComponent
|
||||||
|
|
||||||
users: User[] = []
|
users: (User & { accountMutedStatus: AccountMutedStatus })[] = []
|
||||||
|
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
sort: SortMeta = { field: 'createdAt', order: 1 }
|
sort: SortMeta = { field: 'createdAt', order: 1 }
|
||||||
|
@ -47,6 +48,12 @@ export class UserListComponent extends RestTable implements OnInit {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
userModerationDisplayOptions: UserModerationDisplayType = {
|
||||||
|
instanceAccount: true,
|
||||||
|
instanceUser: true,
|
||||||
|
myAccount: false
|
||||||
|
}
|
||||||
|
|
||||||
requiresEmailVerification = false
|
requiresEmailVerification = false
|
||||||
|
|
||||||
private _selectedColumns: string[]
|
private _selectedColumns: string[]
|
||||||
|
@ -58,6 +65,7 @@ export class UserListComponent extends RestTable implements OnInit {
|
||||||
private confirmService: ConfirmService,
|
private confirmService: ConfirmService,
|
||||||
private serverService: ServerService,
|
private serverService: ServerService,
|
||||||
private auth: AuthService,
|
private auth: AuthService,
|
||||||
|
private blocklist: BlocklistService,
|
||||||
private userAdminService: UserAdminService
|
private userAdminService: UserAdminService
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
|
@ -115,9 +123,9 @@ export class UserListComponent extends RestTable implements OnInit {
|
||||||
|
|
||||||
this.columns = [
|
this.columns = [
|
||||||
{ id: 'username', label: $localize`Username` },
|
{ id: 'username', label: $localize`Username` },
|
||||||
|
{ id: 'role', label: $localize`Role` },
|
||||||
{ id: 'email', label: $localize`Email` },
|
{ id: 'email', label: $localize`Email` },
|
||||||
{ id: 'quota', label: $localize`Video quota` },
|
{ id: 'quota', label: $localize`Video quota` },
|
||||||
{ id: 'role', label: $localize`Role` },
|
|
||||||
{ id: 'createdAt', label: $localize`Created` }
|
{ id: 'createdAt', label: $localize`Created` }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -237,11 +245,35 @@ export class UserListComponent extends RestTable implements OnInit {
|
||||||
search: this.search
|
search: this.search
|
||||||
}).subscribe({
|
}).subscribe({
|
||||||
next: resultList => {
|
next: resultList => {
|
||||||
this.users = resultList.data
|
this.users = resultList.data.map(u => ({
|
||||||
|
...u,
|
||||||
|
|
||||||
|
accountMutedStatus: {
|
||||||
|
...u.account,
|
||||||
|
|
||||||
|
nameWithHost: Actor.CREATE_BY_STRING(u.account.name, u.account.host),
|
||||||
|
|
||||||
|
mutedByInstance: false,
|
||||||
|
mutedByUser: false,
|
||||||
|
mutedServerByInstance: false,
|
||||||
|
mutedServerByUser: false
|
||||||
|
}
|
||||||
|
}))
|
||||||
this.totalRecords = resultList.total
|
this.totalRecords = resultList.total
|
||||||
|
|
||||||
|
this.loadMutedStatus()
|
||||||
},
|
},
|
||||||
|
|
||||||
error: err => this.notifier.error(err.message)
|
error: err => this.notifier.error(err.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private loadMutedStatus () {
|
||||||
|
this.blocklist.getStatus({ accounts: this.users.map(u => u.username + '@' + getAPIHost()) })
|
||||||
|
.subscribe(blockStatus => {
|
||||||
|
for (const user of this.users) {
|
||||||
|
user.accountMutedStatus.mutedByInstance = blockStatus.accounts[user.username + '@' + getAPIHost()].blockedByServer
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,10 @@ function getAbsoluteAPIUrl () {
|
||||||
return absoluteAPIUrl
|
return absoluteAPIUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAPIHost () {
|
||||||
|
return new URL(getAbsoluteAPIUrl()).host
|
||||||
|
}
|
||||||
|
|
||||||
function getAbsoluteEmbedUrl () {
|
function getAbsoluteEmbedUrl () {
|
||||||
let absoluteEmbedUrl = environment.originServerUrl
|
let absoluteEmbedUrl = environment.originServerUrl
|
||||||
if (!absoluteEmbedUrl) {
|
if (!absoluteEmbedUrl) {
|
||||||
|
@ -52,5 +56,6 @@ function objectToFormData (obj: any, form?: FormData, namespace?: string) {
|
||||||
export {
|
export {
|
||||||
objectToFormData,
|
objectToFormData,
|
||||||
getAbsoluteAPIUrl,
|
getAbsoluteAPIUrl,
|
||||||
|
getAPIHost,
|
||||||
getAbsoluteEmbedUrl
|
getAbsoluteEmbedUrl
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getAbsoluteAPIUrl } from '@app/helpers'
|
import { getAbsoluteAPIUrl, getAPIHost } from '@app/helpers'
|
||||||
import { Actor as ServerActor, ActorImage } from '@shared/models'
|
import { Actor as ServerActor, ActorImage } from '@shared/models'
|
||||||
|
|
||||||
export abstract class Actor implements ServerActor {
|
export abstract class Actor implements ServerActor {
|
||||||
|
@ -32,8 +32,7 @@ export abstract class Actor implements ServerActor {
|
||||||
}
|
}
|
||||||
|
|
||||||
static CREATE_BY_STRING (accountName: string, host: string, forceHostname = false) {
|
static CREATE_BY_STRING (accountName: string, host: string, forceHostname = false) {
|
||||||
const absoluteAPIUrl = getAbsoluteAPIUrl()
|
const thisHost = getAPIHost()
|
||||||
const thisHost = new URL(absoluteAPIUrl).host
|
|
||||||
|
|
||||||
if (host.trim() === thisHost && !forceHostname) return accountName
|
if (host.trim() === thisHost && !forceHostname) return accountName
|
||||||
|
|
||||||
|
@ -41,8 +40,7 @@ export abstract class Actor implements ServerActor {
|
||||||
}
|
}
|
||||||
|
|
||||||
static IS_LOCAL (host: string) {
|
static IS_LOCAL (host: string) {
|
||||||
const absoluteAPIUrl = getAbsoluteAPIUrl()
|
const thisHost = getAPIHost()
|
||||||
const thisHost = new URL(absoluteAPIUrl).host
|
|
||||||
|
|
||||||
return host.trim() === thisHost
|
return host.trim() === thisHost
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { SortMeta } from 'primeng/api'
|
import { SortMeta } from 'primeng/api'
|
||||||
import { catchError, map } from 'rxjs/operators'
|
import { from } from 'rxjs'
|
||||||
|
import { catchError, concatMap, map, toArray } from 'rxjs/operators'
|
||||||
import { HttpClient, HttpParams } from '@angular/common/http'
|
import { HttpClient, HttpParams } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { RestExtractor, RestPagination, RestService } from '@app/core'
|
import { RestExtractor, RestPagination, RestService } from '@app/core'
|
||||||
|
@ -120,11 +121,15 @@ export class BlocklistService {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
blockAccountByInstance (account: Pick<Account, 'nameWithHost'>) {
|
blockAccountByInstance (accountsArg: Pick<Account, 'nameWithHost'> | Pick<Account, 'nameWithHost'>[]) {
|
||||||
const body = { accountName: account.nameWithHost }
|
const accounts = Array.isArray(accountsArg) ? accountsArg : [ accountsArg ]
|
||||||
|
|
||||||
return this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts', body)
|
return from(accounts)
|
||||||
.pipe(catchError(err => this.restExtractor.handleError(err)))
|
.pipe(
|
||||||
|
concatMap(a => this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts', { accountName: a.nameWithHost })),
|
||||||
|
toArray(),
|
||||||
|
catchError(err => this.restExtractor.handleError(err))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
unblockAccountByInstance (account: Pick<Account, 'nameWithHost'>) {
|
unblockAccountByInstance (account: Pick<Account, 'nameWithHost'>) {
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
<ng-template #modal>
|
<ng-template #modal>
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h4 i18n class="modal-title">Ban</h4>
|
<h4 i18n class="modal-title">{{ getModalTitle() }}</h4>
|
||||||
|
|
||||||
<my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon>
|
<my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hide()"></my-global-icon>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
<div class="description" i18n>
|
||||||
|
A banned user will no longer be able to login.
|
||||||
|
</div>
|
||||||
|
|
||||||
<form novalidate [formGroup]="form" (ngSubmit)="banUser()">
|
<form novalidate [formGroup]="form" (ngSubmit)="banUser()">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<textarea
|
<textarea
|
||||||
|
@ -17,15 +21,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div i18n>
|
|
||||||
A banned user will no longer be able to login.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<my-peertube-checkbox
|
<my-peertube-checkbox
|
||||||
inputName="banMute" formControlName="mute"
|
inputName="banMute" formControlName="mute"
|
||||||
i18n-labelText labelText="Mute this account"
|
i18n-labelText labelText="Mute to also hide videos/comments"
|
||||||
></my-peertube-checkbox>
|
>
|
||||||
|
</my-peertube-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group inputs">
|
<div class="form-group inputs">
|
||||||
|
@ -34,7 +35,7 @@
|
||||||
(click)="hide()" (key.enter)="hide()"
|
(click)="hide()" (key.enter)="hide()"
|
||||||
>
|
>
|
||||||
|
|
||||||
<input type="submit" i18n-value [value]="modalMessage" class="peertube-button orange-button" [disabled]="!form.valid" />
|
<input type="submit" i18n-value [value]="getModalTitle()" class="peertube-button orange-button" [disabled]="!form.valid" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
@use '_variables' as *;
|
@use '_variables' as *;
|
||||||
@use '_mixins' as *;
|
@use '_mixins' as *;
|
||||||
|
|
||||||
|
.description {
|
||||||
|
font-size: 15px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
@include peertube-textarea(100%, 60px);
|
@include peertube-textarea(100%, 60px);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { forkJoin } from 'rxjs'
|
||||||
import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
|
import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
|
||||||
import { Notifier } from '@app/core'
|
import { Notifier } from '@app/core'
|
||||||
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
|
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
|
||||||
|
@ -42,9 +43,6 @@ export class UserBanModalComponent extends FormReactive implements OnInit {
|
||||||
openModal (user: User | User[]) {
|
openModal (user: User | User[]) {
|
||||||
this.usersToBan = user
|
this.usersToBan = user
|
||||||
this.openedModal = this.modalService.open(this.modal, { centered: true })
|
this.openedModal = this.modalService.open(this.modal, { centered: true })
|
||||||
|
|
||||||
const isSingleUser = !(Array.isArray(this.usersToBan) && this.usersToBan.length > 1)
|
|
||||||
this.modalMessage = isSingleUser ? $localize`Ban this user` : $localize`Ban these users`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hide () {
|
hide () {
|
||||||
|
@ -56,7 +54,13 @@ export class UserBanModalComponent extends FormReactive implements OnInit {
|
||||||
const reason = this.form.value['reason'] || undefined
|
const reason = this.form.value['reason'] || undefined
|
||||||
const mute = this.form.value['mute']
|
const mute = this.form.value['mute']
|
||||||
|
|
||||||
this.userAdminService.banUsers(this.usersToBan, reason)
|
const observables = [
|
||||||
|
this.userAdminService.banUsers(this.usersToBan, reason)
|
||||||
|
]
|
||||||
|
|
||||||
|
if (mute) observables.push(this.muteAccounts())
|
||||||
|
|
||||||
|
forkJoin(observables)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
const message = Array.isArray(this.usersToBan)
|
const message = Array.isArray(this.usersToBan)
|
||||||
|
@ -67,22 +71,6 @@ export class UserBanModalComponent extends FormReactive implements OnInit {
|
||||||
|
|
||||||
this.userBanned.emit(this.usersToBan)
|
this.userBanned.emit(this.usersToBan)
|
||||||
|
|
||||||
if (mute) {
|
|
||||||
const users = Array.isArray(this.usersToBan) ? this.usersToBan : [ this.usersToBan ]
|
|
||||||
users.forEach(user => {
|
|
||||||
const account = new Account(user.account)
|
|
||||||
this.blocklistService.blockAccountByInstance(account)
|
|
||||||
.subscribe({
|
|
||||||
next: () => {
|
|
||||||
this.notifier.success($localize`Account ${user.username} muted by the instance.`)
|
|
||||||
account.mutedByInstance = true
|
|
||||||
},
|
|
||||||
|
|
||||||
error: err => this.notifier.error(err.message)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
this.hide()
|
this.hide()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -90,4 +78,17 @@ export class UserBanModalComponent extends FormReactive implements OnInit {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getModalTitle () {
|
||||||
|
if (Array.isArray(this.usersToBan)) return $localize`Ban ${this.usersToBan.length} users`
|
||||||
|
|
||||||
|
return $localize`Ban "${this.usersToBan.username}"`
|
||||||
|
}
|
||||||
|
|
||||||
|
private muteAccounts () {
|
||||||
|
const accounts = Array.isArray(this.usersToBan)
|
||||||
|
? this.usersToBan.map(u => new Account(u.account))
|
||||||
|
: new Account(this.usersToBan.account)
|
||||||
|
|
||||||
|
return this.blocklistService.blockAccountByInstance(accounts)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,16 @@ import { BlocklistService } from './blocklist.service'
|
||||||
import { BulkService } from './bulk.service'
|
import { BulkService } from './bulk.service'
|
||||||
import { UserBanModalComponent } from './user-ban-modal.component'
|
import { UserBanModalComponent } from './user-ban-modal.component'
|
||||||
|
|
||||||
|
export type AccountMutedStatus =
|
||||||
|
Pick<Account, 'id' | 'nameWithHost' | 'host' | 'userId' |
|
||||||
|
'mutedByInstance' | 'mutedByUser' | 'mutedServerByInstance' | 'mutedServerByUser'>
|
||||||
|
|
||||||
|
export type UserModerationDisplayType = {
|
||||||
|
myAccount?: boolean
|
||||||
|
instanceAccount?: boolean
|
||||||
|
instanceUser?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-user-moderation-dropdown',
|
selector: 'my-user-moderation-dropdown',
|
||||||
templateUrl: './user-moderation-dropdown.component.html'
|
templateUrl: './user-moderation-dropdown.component.html'
|
||||||
|
@ -15,8 +25,8 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
@ViewChild('userBanModal') userBanModal: UserBanModalComponent
|
@ViewChild('userBanModal') userBanModal: UserBanModalComponent
|
||||||
|
|
||||||
@Input() user: User
|
@Input() user: User
|
||||||
@Input() account: Account
|
@Input() account: AccountMutedStatus
|
||||||
@Input() prependActions: DropdownAction<{ user: User, account: Account }>[]
|
@Input() prependActions: DropdownAction<{ user: User, account: AccountMutedStatus }>[]
|
||||||
|
|
||||||
@Input() buttonSize: 'normal' | 'small' = 'normal'
|
@Input() buttonSize: 'normal' | 'small' = 'normal'
|
||||||
@Input() buttonStyled = true
|
@Input() buttonStyled = true
|
||||||
|
@ -24,10 +34,16 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
@Input() label: string
|
@Input() label: string
|
||||||
@Input() container: 'body' | undefined = undefined
|
@Input() container: 'body' | undefined = undefined
|
||||||
|
|
||||||
|
@Input() displayOptions: UserModerationDisplayType = {
|
||||||
|
myAccount: true,
|
||||||
|
instanceAccount: true,
|
||||||
|
instanceUser: true
|
||||||
|
}
|
||||||
|
|
||||||
@Output() userChanged = new EventEmitter()
|
@Output() userChanged = new EventEmitter()
|
||||||
@Output() userDeleted = new EventEmitter()
|
@Output() userDeleted = new EventEmitter()
|
||||||
|
|
||||||
userActions: DropdownAction<{ user: User, account: Account }>[][] = []
|
userActions: DropdownAction<{ user: User, account: AccountMutedStatus }>[][] = []
|
||||||
|
|
||||||
requiresEmailVerification = false
|
requiresEmailVerification = false
|
||||||
|
|
||||||
|
@ -111,7 +127,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
blockAccountByUser (account: Account) {
|
blockAccountByUser (account: AccountMutedStatus) {
|
||||||
this.blocklistService.blockAccountByUser(account)
|
this.blocklistService.blockAccountByUser(account)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
|
@ -125,7 +141,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
unblockAccountByUser (account: Account) {
|
unblockAccountByUser (account: AccountMutedStatus) {
|
||||||
this.blocklistService.unblockAccountByUser(account)
|
this.blocklistService.unblockAccountByUser(account)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
|
@ -167,7 +183,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
blockAccountByInstance (account: Account) {
|
blockAccountByInstance (account: AccountMutedStatus) {
|
||||||
this.blocklistService.blockAccountByInstance(account)
|
this.blocklistService.blockAccountByInstance(account)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
|
@ -181,7 +197,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
unblockAccountByInstance (account: Account) {
|
unblockAccountByInstance (account: AccountMutedStatus) {
|
||||||
this.blocklistService.unblockAccountByInstance(account)
|
this.blocklistService.unblockAccountByInstance(account)
|
||||||
.subscribe({
|
.subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
|
@ -246,7 +262,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
return user && this.authService.getUser().id === user.id
|
return user && this.authService.getUser().id === user.id
|
||||||
}
|
}
|
||||||
|
|
||||||
private isMyAccount (account: Account) {
|
private isMyAccount (account: AccountMutedStatus) {
|
||||||
return account && this.authService.getUser().account.id === account.id
|
return account && this.authService.getUser().account.id === account.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,9 +283,9 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildMyAccountModerationActions () {
|
private buildMyAccountModerationActions () {
|
||||||
if (!this.account || !this.authService.isLoggedIn()) return []
|
if (!this.account || !this.displayOptions.myAccount || !this.authService.isLoggedIn()) return []
|
||||||
|
|
||||||
const myAccountActions: DropdownAction<{ user: User, account: Account }>[] = [
|
const myAccountActions: DropdownAction<{ user: User, account: AccountMutedStatus }>[] = [
|
||||||
{
|
{
|
||||||
label: $localize`My account moderation`,
|
label: $localize`My account moderation`,
|
||||||
class: [ 'red' ],
|
class: [ 'red' ],
|
||||||
|
@ -315,9 +331,9 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
|
|
||||||
const authUser = this.authService.getUser()
|
const authUser = this.authService.getUser()
|
||||||
|
|
||||||
let instanceActions: DropdownAction<{ user: User, account: Account }>[] = []
|
let instanceActions: DropdownAction<{ user: User, account: AccountMutedStatus }>[] = []
|
||||||
|
|
||||||
if (this.user && authUser.hasRight(UserRight.MANAGE_USERS) && authUser.canManage(this.user)) {
|
if (this.user && this.displayOptions.instanceUser && authUser.hasRight(UserRight.MANAGE_USERS) && authUser.canManage(this.user)) {
|
||||||
instanceActions = instanceActions.concat([
|
instanceActions = instanceActions.concat([
|
||||||
{
|
{
|
||||||
label: $localize`Edit user`,
|
label: $localize`Edit user`,
|
||||||
|
@ -351,7 +367,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instance actions on account blocklists
|
// Instance actions on account blocklists
|
||||||
if (this.account && authUser.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)) {
|
if (this.account && this.displayOptions.instanceAccount && authUser.hasRight(UserRight.MANAGE_ACCOUNTS_BLOCKLIST)) {
|
||||||
instanceActions = instanceActions.concat([
|
instanceActions = instanceActions.concat([
|
||||||
{
|
{
|
||||||
label: $localize`Mute this account`,
|
label: $localize`Mute this account`,
|
||||||
|
@ -369,7 +385,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Instance actions on server blocklists
|
// Instance actions on server blocklists
|
||||||
if (this.account && authUser.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)) {
|
if (this.account && this.displayOptions.instanceAccount && authUser.hasRight(UserRight.MANAGE_SERVERS_BLOCKLIST)) {
|
||||||
instanceActions = instanceActions.concat([
|
instanceActions = instanceActions.concat([
|
||||||
{
|
{
|
||||||
label: $localize`Mute the instance`,
|
label: $localize`Mute the instance`,
|
||||||
|
@ -386,7 +402,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.account && authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT)) {
|
if (this.account && this.displayOptions.instanceAccount && authUser.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT)) {
|
||||||
instanceActions = instanceActions.concat([
|
instanceActions = instanceActions.concat([
|
||||||
{
|
{
|
||||||
label: $localize`Remove comments from your instance`,
|
label: $localize`Remove comments from your instance`,
|
||||||
|
|
Loading…
Reference in New Issue