mirror of https://github.com/Chocobozzz/PeerTube
Factorize rest-table and fix/simplify SQL
parent
b8cf27c0f8
commit
0251197e24
|
@ -14,8 +14,6 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
|
||||||
export class FollowersListComponent extends RestTable implements OnInit {
|
export class FollowersListComponent extends RestTable implements OnInit {
|
||||||
followers: ActorFollow[] = []
|
followers: ActorFollow[] = []
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
rowsPerPageOptions = [ 20, 50, 100 ]
|
|
||||||
rowsPerPage = this.rowsPerPageOptions[0]
|
|
||||||
sort: SortMeta = { field: 'createdAt', order: -1 }
|
sort: SortMeta = { field: 'createdAt', order: -1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,6 @@ export class FollowingListComponent extends RestTable implements OnInit {
|
||||||
|
|
||||||
following: ActorFollow[] = []
|
following: ActorFollow[] = []
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
rowsPerPageOptions = [ 20, 50, 100 ]
|
|
||||||
rowsPerPage = this.rowsPerPageOptions[0]
|
|
||||||
sort: SortMeta = { field: 'createdAt', order: -1 }
|
sort: SortMeta = { field: 'createdAt', order: -1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit
|
||||||
|
|
||||||
videoRedundancies: VideoRedundancy[] = []
|
videoRedundancies: VideoRedundancy[] = []
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
rowsPerPage = 10
|
|
||||||
|
|
||||||
sort: SortMeta = { field: 'name', order: 1 }
|
sort: SortMeta = { field: 'name', order: 1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
|
|
|
@ -14,8 +14,6 @@ import { Actor } from '@app/shared/actor/actor.model'
|
||||||
export class InstanceAccountBlocklistComponent extends RestTable implements OnInit {
|
export class InstanceAccountBlocklistComponent extends RestTable implements OnInit {
|
||||||
blockedAccounts: AccountBlock[] = []
|
blockedAccounts: AccountBlock[] = []
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
rowsPerPageOptions = [ 20, 50, 100 ]
|
|
||||||
rowsPerPage = this.rowsPerPageOptions[0]
|
|
||||||
sort: SortMeta = { field: 'createdAt', order: -1 }
|
sort: SortMeta = { field: 'createdAt', order: -1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,6 @@ export class InstanceServerBlocklistComponent extends RestTable implements OnIni
|
||||||
|
|
||||||
blockedServers: ServerBlock[] = []
|
blockedServers: ServerBlock[] = []
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
rowsPerPageOptions = [ 20, 50, 100 ]
|
|
||||||
rowsPerPage = this.rowsPerPageOptions[0]
|
|
||||||
sort: SortMeta = { field: 'createdAt', order: -1 }
|
sort: SortMeta = { field: 'createdAt', order: -1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<th style="width: 40px;"></th>
|
<th style="width: 40px;"></th>
|
||||||
<th style="width: 20%;" pResizableColumn i18n>Reporter</th>
|
<th style="width: 20%;" pResizableColumn i18n>Reporter</th>
|
||||||
<th i18n>Video</th>
|
<th i18n>Video</th>
|
||||||
<th style="width:190px;" i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>
|
<th style="width: 190px;" i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>
|
||||||
<th i18n pSortableColumn="state" style="width: 80px;">State <p-sortIcon field="state"></p-sortIcon></th>
|
<th i18n pSortableColumn="state" style="width: 80px;">State <p-sortIcon field="state"></p-sortIcon></th>
|
||||||
<th style="width: 120px;"></th>
|
<th style="width: 120px;"></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -59,7 +59,9 @@
|
||||||
<span
|
<span
|
||||||
class="video-table-video-image-label" *ngIf="videoAbuse.count > 1"
|
class="video-table-video-image-label" *ngIf="videoAbuse.count > 1"
|
||||||
i18n-title title="This video has been reported multiple times."
|
i18n-title title="This video has been reported multiple times."
|
||||||
>{{ videoAbuse.nth }}/{{ videoAbuse.count }}</span>
|
>
|
||||||
|
{{ videoAbuse.nth }}/{{ videoAbuse.count }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="video-table-video-text">
|
<div class="video-table-video-text">
|
||||||
<div>
|
<div>
|
||||||
|
@ -67,7 +69,7 @@
|
||||||
<span *ngIf="!videoAbuse.video.blacklisted" class="glyphicon glyphicon-new-window"></span>
|
<span *ngIf="!videoAbuse.video.blacklisted" class="glyphicon glyphicon-new-window"></span>
|
||||||
<span *ngIf="videoAbuse.video.blacklisted" i18n-title title="Video was blacklisted" class="glyphicon glyphicon-ban-circle"></span>
|
<span *ngIf="videoAbuse.video.blacklisted" i18n-title title="Video was blacklisted" class="glyphicon glyphicon-ban-circle"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-muted">by {{ videoAbuse.video.channel?.displayName }} on {{ videoAbuse.video.channel?.host }} </div>
|
<div class="text-muted" i18n>by {{ videoAbuse.video.channel?.displayName }} on {{ videoAbuse.video.channel?.host }} </div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@ -75,13 +77,15 @@
|
||||||
|
|
||||||
<td *ngIf="videoAbuse.video.deleted" class="c-hand" [pRowToggler]="videoAbuse">
|
<td *ngIf="videoAbuse.video.deleted" class="c-hand" [pRowToggler]="videoAbuse">
|
||||||
<div class="video-table-video" i18n-title title="Video was deleted">
|
<div class="video-table-video" i18n-title title="Video was deleted">
|
||||||
<div class="video-table-video-image"><span i18n>Deleted</span></div>
|
<div class="video-table-video-image">
|
||||||
|
<span i18n>Deleted</span>
|
||||||
|
</div>
|
||||||
<div class="video-table-video-text">
|
<div class="video-table-video-text">
|
||||||
<div>
|
<div>
|
||||||
{{ videoAbuse.video.name }}
|
{{ videoAbuse.video.name }}
|
||||||
<span class="glyphicon glyphicon-trash"></span>
|
<span class="glyphicon glyphicon-trash"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-muted">by {{ videoAbuse.video.channel?.displayName }} on {{ videoAbuse.video.channel?.host }} </div>
|
<div class="text-muted" i18n>by {{ videoAbuse.video.channel?.displayName }} on {{ videoAbuse.video.channel?.host }} </div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -107,8 +111,10 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td class="expand-cell" colspan="6">
|
<td class="expand-cell" colspan="6">
|
||||||
<div class="d-flex moderation-expanded">
|
<div class="d-flex moderation-expanded">
|
||||||
<!-- report metadata -->
|
<!-- report left part (report details) -->
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
|
|
||||||
|
<!-- report metadata -->
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<span class="col-3 moderation-expanded-label" i18n>Reporter</span>
|
<span class="col-3 moderation-expanded-label" i18n>Reporter</span>
|
||||||
<span class="col-9 moderation-expanded-text">
|
<span class="col-9 moderation-expanded-text">
|
||||||
|
@ -128,6 +134,7 @@
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<span class="col-3 moderation-expanded-label" i18n>Reportee</span>
|
<span class="col-3 moderation-expanded-label" i18n>Reportee</span>
|
||||||
<span class="col-9 moderation-expanded-text">
|
<span class="col-9 moderation-expanded-text">
|
||||||
|
@ -147,6 +154,7 @@
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<span class="col-3 moderation-expanded-label" i18n>Updated</span>
|
<span class="col-3 moderation-expanded-label" i18n>Updated</span>
|
||||||
<time class="col-9 moderation-expanded-text video-details-date-updated">{{ videoAbuse.updatedAt | date: 'medium' }}</time>
|
<time class="col-9 moderation-expanded-text video-details-date-updated">{{ videoAbuse.updatedAt | date: 'medium' }}</time>
|
||||||
|
@ -157,16 +165,20 @@
|
||||||
<span class="col-3 moderation-expanded-label" i18n>Report #{{ videoAbuse.id }}</span>
|
<span class="col-3 moderation-expanded-label" i18n>Report #{{ videoAbuse.id }}</span>
|
||||||
<span class="col-9 moderation-expanded-text" [innerHTML]="videoAbuse.reasonHtml"></span>
|
<span class="col-9 moderation-expanded-text" [innerHTML]="videoAbuse.reasonHtml"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-3 d-flex" *ngIf="videoAbuse.moderationComment">
|
<div class="mt-3 d-flex" *ngIf="videoAbuse.moderationComment">
|
||||||
<span class="col-3 moderation-expanded-label" i18n>Note</span>
|
<span class="col-3 moderation-expanded-label" i18n>Note</span>
|
||||||
<span class="col-9 moderation-expanded-text" [innerHTML]="videoAbuse.moderationCommentHtml"></span>
|
<span class="col-9 moderation-expanded-text" [innerHTML]="videoAbuse.moderationCommentHtml"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- report right part (video details) -->
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<div class="screenratio">
|
<div class="screenratio">
|
||||||
<div *ngIf="videoAbuse.video.deleted || videoAbuse.video.blacklisted">
|
<div *ngIf="videoAbuse.video.deleted || videoAbuse.video.blacklisted">
|
||||||
<span i18n>The video was {{ videoAbuse.video.deleted ? 'deleted' : 'blacklisted' }}</span>
|
<span i18n *ngIf="videoAbuse.video.deleted">The video was deleted</span>
|
||||||
|
<span i18n *ngIf="!videoAbuse.video.deleted">The video was blacklisted</span>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!videoAbuse.video.deleted && !videoAbuse.video.blacklisted" [innerHTML]="videoAbuse.embedHtml"></div>
|
<div *ngIf="!videoAbuse.video.deleted && !videoAbuse.video.blacklisted" [innerHTML]="videoAbuse.embedHtml"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -29,8 +29,6 @@ export class VideoAbuseListComponent extends RestTable implements OnInit, AfterV
|
||||||
|
|
||||||
videoAbuses: (VideoAbuse & { moderationCommentHtml?: string, reasonHtml?: string })[] = []
|
videoAbuses: (VideoAbuse & { moderationCommentHtml?: string, reasonHtml?: string })[] = []
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
rowsPerPageOptions = [ 20, 50, 100 ]
|
|
||||||
rowsPerPage = this.rowsPerPageOptions[0]
|
|
||||||
sort: SortMeta = { field: 'createdAt', order: 1 }
|
sort: SortMeta = { field: 'createdAt', order: 1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
|
|
||||||
|
@ -199,7 +197,7 @@ export class VideoAbuseListComponent extends RestTable implements OnInit, AfterV
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit () {
|
ngAfterViewInit () {
|
||||||
this.setTableFilter(this.search)
|
if (this.search) this.setTableFilter(this.search)
|
||||||
}
|
}
|
||||||
|
|
||||||
getIdentifier () {
|
getIdentifier () {
|
||||||
|
|
|
@ -17,8 +17,6 @@ import { MarkdownService } from '@app/shared/renderer'
|
||||||
export class VideoBlacklistListComponent extends RestTable implements OnInit {
|
export class VideoBlacklistListComponent extends RestTable implements OnInit {
|
||||||
blacklist: (VideoBlacklist & { reasonHtml?: string })[] = []
|
blacklist: (VideoBlacklist & { reasonHtml?: string })[] = []
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
rowsPerPageOptions = [ 20, 50, 100 ]
|
|
||||||
rowsPerPage = this.rowsPerPageOptions[0]
|
|
||||||
sort: SortMeta = { field: 'createdAt', order: -1 }
|
sort: SortMeta = { field: 'createdAt', order: -1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
listBlacklistTypeFilter: VideoBlacklistType = undefined
|
listBlacklistTypeFilter: VideoBlacklistType = undefined
|
||||||
|
|
|
@ -40,7 +40,6 @@ export class JobsComponent extends RestTable implements OnInit {
|
||||||
|
|
||||||
jobs: Job[] = []
|
jobs: Job[] = []
|
||||||
totalRecords: number
|
totalRecords: number
|
||||||
rowsPerPage = 10
|
|
||||||
sort: SortMeta = { field: 'createdAt', order: -1 }
|
sort: SortMeta = { field: 'createdAt', order: -1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ export class UserListComponent extends RestTable implements OnInit {
|
||||||
|
|
||||||
users: User[] = []
|
users: User[] = []
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
rowsPerPage = 10
|
|
||||||
sort: SortMeta = { field: 'createdAt', order: 1 }
|
sort: SortMeta = { field: 'createdAt', order: 1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import { AccountBlock, BlocklistService } from '@app/shared/blocklist'
|
||||||
export class MyAccountBlocklistComponent extends RestTable implements OnInit {
|
export class MyAccountBlocklistComponent extends RestTable implements OnInit {
|
||||||
blockedAccounts: AccountBlock[] = []
|
blockedAccounts: AccountBlock[] = []
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
rowsPerPage = 10
|
|
||||||
sort: SortMeta = { field: 'createdAt', order: -1 }
|
sort: SortMeta = { field: 'createdAt', order: -1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ import { BlocklistService } from '@app/shared/blocklist'
|
||||||
export class MyAccountServerBlocklistComponent extends RestTable implements OnInit {
|
export class MyAccountServerBlocklistComponent extends RestTable implements OnInit {
|
||||||
blockedServers: ServerBlock[] = []
|
blockedServers: ServerBlock[] = []
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
rowsPerPage = 10
|
|
||||||
sort: SortMeta = { field: 'createdAt', order: -1 }
|
sort: SortMeta = { field: 'createdAt', order: -1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ import { MyAccountAcceptOwnershipComponent } from './my-account-accept-ownership
|
||||||
export class MyAccountOwnershipComponent extends RestTable implements OnInit {
|
export class MyAccountOwnershipComponent extends RestTable implements OnInit {
|
||||||
videoChangeOwnerships: VideoChangeOwnership[] = []
|
videoChangeOwnerships: VideoChangeOwnership[] = []
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
rowsPerPage = 10
|
|
||||||
sort: SortMeta = { field: 'createdAt', order: -1 }
|
sort: SortMeta = { field: 'createdAt', order: -1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core'
|
||||||
import { RestPagination, RestTable } from '@app/shared'
|
import { RestPagination, RestTable } from '@app/shared'
|
||||||
import { SortMeta } from 'primeng/api'
|
import { SortMeta } from 'primeng/api'
|
||||||
import { Notifier } from '@app/core'
|
import { Notifier } from '@app/core'
|
||||||
import { I18n } from '@ngx-translate/i18n-polyfill'
|
|
||||||
import { VideoImport, VideoImportState } from '../../../../../shared/models/videos'
|
import { VideoImport, VideoImportState } from '../../../../../shared/models/videos'
|
||||||
import { VideoImportService } from '@app/shared/video-import'
|
import { VideoImportService } from '@app/shared/video-import'
|
||||||
|
|
||||||
|
@ -14,7 +13,6 @@ import { VideoImportService } from '@app/shared/video-import'
|
||||||
export class MyAccountVideoImportsComponent extends RestTable implements OnInit {
|
export class MyAccountVideoImportsComponent extends RestTable implements OnInit {
|
||||||
videoImports: VideoImport[] = []
|
videoImports: VideoImport[] = []
|
||||||
totalRecords = 0
|
totalRecords = 0
|
||||||
rowsPerPage = 10
|
|
||||||
sort: SortMeta = { field: 'createdAt', order: 1 }
|
sort: SortMeta = { field: 'createdAt', order: 1 }
|
||||||
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,13 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
|
||||||
export abstract class RestTable {
|
export abstract class RestTable {
|
||||||
|
|
||||||
abstract totalRecords: number
|
abstract totalRecords: number
|
||||||
abstract rowsPerPage: number
|
|
||||||
abstract sort: SortMeta
|
abstract sort: SortMeta
|
||||||
abstract pagination: RestPagination
|
abstract pagination: RestPagination
|
||||||
|
|
||||||
search: string
|
search: string
|
||||||
|
rowsPerPageOptions = [ 10, 20, 50, 100 ]
|
||||||
|
rowsPerPage = this.rowsPerPageOptions[0]
|
||||||
|
|
||||||
private searchStream: Subject<string>
|
private searchStream: Subject<string>
|
||||||
|
|
||||||
abstract getIdentifier (): string
|
abstract getIdentifier (): string
|
||||||
|
|
|
@ -7,7 +7,7 @@ async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: stri
|
||||||
let videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, null, videoUUID)
|
let videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, null, videoUUID)
|
||||||
|
|
||||||
if (!videoAbuse) {
|
if (!videoAbuse) {
|
||||||
const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined
|
const userId = res.locals.oauth?.token.User.id
|
||||||
const video = await fetchVideo(videoUUID, 'all', userId)
|
const video = await fetchVideo(videoUUID, 'all', userId)
|
||||||
|
|
||||||
if (video) videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, video.id)
|
if (video) videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, video.id)
|
||||||
|
|
|
@ -11,10 +11,8 @@ async function up (utils: {
|
||||||
allowNull: true
|
allowNull: true
|
||||||
}
|
}
|
||||||
await utils.queryInterface.addColumn('videoAbuse', 'deletedVideo', deletedVideo)
|
await utils.queryInterface.addColumn('videoAbuse', 'deletedVideo', deletedVideo)
|
||||||
await utils.sequelize.query(`ALTER TABLE "videoAbsue" ALTER COLUMN "videoId" DROP NOT NULL;`)
|
await utils.sequelize.query(`ALTER TABLE "videoAbuse" ALTER COLUMN "videoId" DROP NOT NULL;`)
|
||||||
await utils.sequelize.query(`ALTER TABLE "videoAbuse" DROP CONSTRAINT IF EXISTS "videoAbuse_videoId_fkey";`)
|
await utils.sequelize.query(`ALTER TABLE "videoAbuse" DROP CONSTRAINT IF EXISTS "videoAbuse_videoId_fkey";`)
|
||||||
await utils.sequelize.query(`ALTER TABLE "videoAbuse" ADD CONSTRAINT "videoAbuse_videoId_fkey"
|
|
||||||
FOREIGN KEY ("videoId") REFERENCES video(id) ON UPDATE CASCADE ON DELETE SET NULL;`)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,8 +133,8 @@ export class AccountBlocklistModel extends Model<AccountBlocklistModel> {
|
||||||
if (search) {
|
if (search) {
|
||||||
Object.assign(where, {
|
Object.assign(where, {
|
||||||
[Op.or]: [
|
[Op.or]: [
|
||||||
{ ...searchAttribute(search, '$BlockedAccount.name$') },
|
searchAttribute(search, '$BlockedAccount.name$'),
|
||||||
{ ...searchAttribute(search, '$BlockedAccount.Actor.url$') }
|
searchAttribute(search, '$BlockedAccount.Actor.url$')
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,8 +139,6 @@ export class ServerBlocklistModel extends Model<ServerBlocklistModel> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(search)
|
|
||||||
|
|
||||||
return ServerBlocklistModel
|
return ServerBlocklistModel
|
||||||
.scope([ ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_SERVER ])
|
.scope([ ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_SERVER ])
|
||||||
.findAndCountAll<MServerBlocklistAccountServer>(query)
|
.findAndCountAll<MServerBlocklistAccountServer>(query)
|
||||||
|
|
|
@ -208,13 +208,15 @@ function buildDirectionAndField (value: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function searchAttribute (sourceField, targetField) {
|
function searchAttribute (sourceField, targetField) {
|
||||||
return sourceField
|
if (sourceField) {
|
||||||
? {
|
return {
|
||||||
[targetField]: {
|
[targetField]: {
|
||||||
[Op.iLike]: `%${sourceField}%`
|
[Op.iLike]: `%${sourceField}%`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
: {}
|
} else {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -15,7 +15,7 @@ import { VideoAbuseState, VideoDetails } from '../../../shared'
|
||||||
import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants'
|
import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants'
|
||||||
import { MUserAccountId, MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models'
|
import { MUserAccountId, MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models'
|
||||||
import * as Bluebird from 'bluebird'
|
import * as Bluebird from 'bluebird'
|
||||||
import { literal, Op } from 'sequelize'
|
import { literal, Op, Sequelize } from 'sequelize'
|
||||||
import { ThumbnailModel } from './thumbnail'
|
import { ThumbnailModel } from './thumbnail'
|
||||||
import { VideoBlacklistModel } from './video-blacklist'
|
import { VideoBlacklistModel } from './video-blacklist'
|
||||||
import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel'
|
import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel'
|
||||||
|
@ -31,7 +31,7 @@ export enum ScopeNames {
|
||||||
searchVideo?: string
|
searchVideo?: string
|
||||||
searchVideoChannel?: string
|
searchVideoChannel?: string
|
||||||
serverAccountId: number
|
serverAccountId: number
|
||||||
userAccountId: any
|
userAccountId: number
|
||||||
}) => {
|
}) => {
|
||||||
let where = {
|
let where = {
|
||||||
reporterAccountId: {
|
reporterAccountId: {
|
||||||
|
@ -45,28 +45,28 @@ export enum ScopeNames {
|
||||||
{
|
{
|
||||||
[Op.and]: [
|
[Op.and]: [
|
||||||
{ videoId: { [Op.not]: null } },
|
{ videoId: { [Op.not]: null } },
|
||||||
{ '$Video.name$': { [Op.iLike]: `%${options.search}%` } }
|
searchAttribute(options.search, '$Video.name$')
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[Op.and]: [
|
[Op.and]: [
|
||||||
{ videoId: { [Op.not]: null } },
|
{ videoId: { [Op.not]: null } },
|
||||||
{ '$Video.VideoChannel.name$': { [Op.iLike]: `%${options.search}%` } }
|
searchAttribute(options.search, '$Video.VideoChannel.name$')
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[Op.and]: [
|
[Op.and]: [
|
||||||
{ deletedVideo: { [Op.not]: null } },
|
{ deletedVideo: { [Op.not]: null } },
|
||||||
{ deletedVideo: { name: { [Op.iLike]: `%${options.search}%` } } }
|
{ deletedVideo: searchAttribute(options.search, 'name') }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
[Op.and]: [
|
[Op.and]: [
|
||||||
{ deletedVideo: { [Op.not]: null } },
|
{ deletedVideo: { [Op.not]: null } },
|
||||||
{ deletedVideo: { channel: { displayName: { [Op.iLike]: `%${options.search}%` } } } }
|
{ deletedVideo: { channel: searchAttribute(options.search, 'displayName') } }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ '$Account.name$': { [Op.iLike]: `%${options.search}%` } }
|
searchAttribute(options.search, '$Account.name$')
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -77,13 +77,9 @@ export enum ScopeNames {
|
||||||
[
|
[
|
||||||
literal(
|
literal(
|
||||||
'(' +
|
'(' +
|
||||||
'SELECT t.count ' +
|
'SELECT count(*) ' +
|
||||||
'FROM ( ' +
|
'FROM "videoAbuse" ' +
|
||||||
'SELECT id, ' +
|
'WHERE "videoId" = "VideoAbuseModel"."videoId" ' +
|
||||||
'count(id) OVER (PARTITION BY "videoId") ' +
|
|
||||||
'FROM "videoAbuse" ' +
|
|
||||||
') t ' +
|
|
||||||
'WHERE t.id = "VideoAbuseModel".id ' +
|
|
||||||
')'
|
')'
|
||||||
),
|
),
|
||||||
'countReportsForVideo'
|
'countReportsForVideo'
|
||||||
|
@ -118,20 +114,11 @@ export enum ScopeNames {
|
||||||
[
|
[
|
||||||
literal(
|
literal(
|
||||||
'(' +
|
'(' +
|
||||||
'WITH ' +
|
'SELECT count(DISTINCT "videoAbuse"."id") ' +
|
||||||
'ids AS ( ' +
|
|
||||||
'SELECT "account"."id" ' +
|
|
||||||
'FROM "account" ' +
|
|
||||||
'INNER JOIN "videoChannel" ON "videoChannel"."accountId" = "account"."id" ' +
|
|
||||||
'INNER JOIN "video" ON "video"."channelId" = "videoChannel"."id" ' +
|
|
||||||
'WHERE "video"."id" = "VideoAbuseModel"."videoId" ' +
|
|
||||||
') ' +
|
|
||||||
'SELECT count("videoAbuse"."id") ' +
|
|
||||||
'FROM "videoAbuse" ' +
|
'FROM "videoAbuse" ' +
|
||||||
'INNER JOIN "video" ON "video"."id" = "videoAbuse"."videoId" ' +
|
'INNER JOIN "video" ON "video"."id" = "videoAbuse"."videoId" ' +
|
||||||
'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' +
|
'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' +
|
||||||
'INNER JOIN "account" ON "videoChannel"."accountId" = "account"."id" ' +
|
'INNER JOIN "account" ON "videoChannel"."accountId" = "Video->VideoChannel"."accountId" ' +
|
||||||
'INNER JOIN ids ON "account"."id" = ids.id ' +
|
|
||||||
')'
|
')'
|
||||||
),
|
),
|
||||||
'countReportsForReportee'
|
'countReportsForReportee'
|
||||||
|
@ -142,19 +129,19 @@ export enum ScopeNames {
|
||||||
{
|
{
|
||||||
model: AccountModel,
|
model: AccountModel,
|
||||||
required: true,
|
required: true,
|
||||||
where: { ...searchAttribute(options.searchReporter, 'name') }
|
where: searchAttribute(options.searchReporter, 'name')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: VideoModel,
|
model: VideoModel,
|
||||||
required: false,
|
required: false,
|
||||||
where: { ...searchAttribute(options.searchVideo, 'name') },
|
where: searchAttribute(options.searchVideo, 'name'),
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: ThumbnailModel
|
model: ThumbnailModel
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, { withAccount: true } as SummaryOptions ] }),
|
model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, { withAccount: true } as SummaryOptions ] }),
|
||||||
where: { ...searchAttribute(options.searchVideoChannel, 'name') }
|
where: searchAttribute(options.searchVideoChannel, 'name')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
attributes: [ 'id', 'reason', 'unfederated' ],
|
attributes: [ 'id', 'reason', 'unfederated' ],
|
||||||
|
|
|
@ -78,7 +78,7 @@ export class VideoBlacklistModel extends Model<VideoBlacklistModel> {
|
||||||
{
|
{
|
||||||
model: VideoModel,
|
model: VideoModel,
|
||||||
required: true,
|
required: true,
|
||||||
where: { ...searchAttribute(search, 'name') },
|
where: searchAttribute(search, 'name'),
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, { withAccount: true } as SummaryOptions ] }),
|
model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, { withAccount: true } as SummaryOptions ] }),
|
||||||
|
|
|
@ -813,10 +813,8 @@ export class VideoModel extends Model<VideoModel> {
|
||||||
const details = instance.toFormattedDetailsJSON()
|
const details = instance.toFormattedDetailsJSON()
|
||||||
|
|
||||||
for (const abuse of instance.VideoAbuses) {
|
for (const abuse of instance.VideoAbuses) {
|
||||||
tasks.push((_ => {
|
abuse.deletedVideo = details
|
||||||
abuse.deletedVideo = details
|
tasks.push(abuse.save({ transaction: options.transaction }))
|
||||||
return abuse.save({ transaction: options.transaction })
|
|
||||||
})())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.all(tasks)
|
Promise.all(tasks)
|
||||||
|
|
Loading…
Reference in New Issue