Factorize rest-table and fix/simplify SQL
authorRigel Kent <sendmemail@rigelk.eu>
Mon, 20 Apr 2020 09:20:12 +0000 (11:20 +0200)
committerRigel Kent <par@rigelk.eu>
Fri, 1 May 2020 14:41:02 +0000 (16:41 +0200)
23 files changed:
client/src/app/+admin/follows/followers-list/followers-list.component.ts
client/src/app/+admin/follows/following-list/following-list.component.ts
client/src/app/+admin/follows/video-redundancies-list/video-redundancies-list.component.ts
client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.ts
client/src/app/+admin/moderation/instance-blocklist/instance-server-blocklist.component.ts
client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.html
client/src/app/+admin/moderation/video-abuse-list/video-abuse-list.component.ts
client/src/app/+admin/moderation/video-blacklist-list/video-blacklist-list.component.ts
client/src/app/+admin/system/jobs/jobs.component.ts
client/src/app/+admin/users/user-list/user-list.component.ts
client/src/app/+my-account/my-account-blocklist/my-account-blocklist.component.ts
client/src/app/+my-account/my-account-blocklist/my-account-server-blocklist.component.ts
client/src/app/+my-account/my-account-ownership/my-account-ownership.component.ts
client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.ts
client/src/app/shared/rest/rest-table.ts
server/helpers/middlewares/video-abuses.ts
server/initializers/migrations/0490-abuse-video.ts
server/models/account/account-blocklist.ts
server/models/server/server-blocklist.ts
server/models/utils.ts
server/models/video/video-abuse.ts
server/models/video/video-blacklist.ts
server/models/video/video.ts

index 00f447bb211f60ac3910b9d2deaae3400a98944a..17352a60104c7cb264605f4b13e94c555799167f 100644 (file)
@@ -14,8 +14,6 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
 export class FollowersListComponent extends RestTable implements OnInit {
   followers: ActorFollow[] = []
   totalRecords = 0
-  rowsPerPageOptions = [ 20, 50, 100 ]
-  rowsPerPage = this.rowsPerPageOptions[0]
   sort: SortMeta = { field: 'createdAt', order: -1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
 
index e1b1f8aeba8b01ec76e08efb4b130b6b4b044b30..6ddbf02d6deb04e1594ed55b12c28e61f8a86c05 100644 (file)
@@ -18,8 +18,6 @@ export class FollowingListComponent extends RestTable implements OnInit {
 
   following: ActorFollow[] = []
   totalRecords = 0
-  rowsPerPageOptions = [ 20, 50, 100 ]
-  rowsPerPage = this.rowsPerPageOptions[0]
   sort: SortMeta = { field: 'createdAt', order: -1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
 
index f91800175a08f4945720ab278bff4bc12b65abda..267a1f58efeecc838a12c8e6e9847912658f87df 100644 (file)
@@ -20,7 +20,6 @@ export class VideoRedundanciesListComponent extends RestTable implements OnInit
 
   videoRedundancies: VideoRedundancy[] = []
   totalRecords = 0
-  rowsPerPage = 10
 
   sort: SortMeta = { field: 'name', order: 1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
index 6bd0152345ff3196df8a89cfaadd0c21a806ecb3..73a9ae75d4ad577a3d3f5cf06ce3cf07331f4c88 100644 (file)
@@ -14,8 +14,6 @@ import { Actor } from '@app/shared/actor/actor.model'
 export class InstanceAccountBlocklistComponent extends RestTable implements OnInit {
   blockedAccounts: AccountBlock[] = []
   totalRecords = 0
-  rowsPerPageOptions = [ 20, 50, 100 ]
-  rowsPerPage = this.rowsPerPageOptions[0]
   sort: SortMeta = { field: 'createdAt', order: -1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
 
index 344e2d135d27d0259cf91b73779d4b22c72e22d1..559c9c0b0ca289d3590a515a20f8d2c1bdaf0056 100644 (file)
@@ -17,8 +17,6 @@ export class InstanceServerBlocklistComponent extends RestTable implements OnIni
 
   blockedServers: ServerBlock[] = []
   totalRecords = 0
-  rowsPerPageOptions = [ 20, 50, 100 ]
-  rowsPerPage = this.rowsPerPageOptions[0]
   sort: SortMeta = { field: 'createdAt', order: -1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
 
index 6dacfe243fd7b0dd0d6cb5a1a03012acbca7e72c..4afa2850bf5d37f20d6648fbe0524bd13e40c907 100644 (file)
@@ -20,7 +20,7 @@
       <th style="width: 40px;"></th>
       <th style="width: 20%;" pResizableColumn i18n>Reporter</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 style="width: 120px;"></th>
     </tr>
@@ -59,7 +59,9 @@
               <span
                 class="video-table-video-image-label" *ngIf="videoAbuse.count > 1"
                 i18n-title title="This video has been reported multiple times."
-              >{{ videoAbuse.nth }}/{{ videoAbuse.count }}</span>
+              >
+                {{ videoAbuse.nth }}/{{ videoAbuse.count }}
+              </span>
             </div>
             <div class="video-table-video-text">
               <div>
@@ -67,7 +69,7 @@
                 <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>
               </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>
         </a>
 
       <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-image"><span i18n>Deleted</span></div>
+          <div class="video-table-video-image">
+            <span i18n>Deleted</span>
+          </div>
           <div class="video-table-video-text">
             <div>
               {{ videoAbuse.video.name }}
               <span class="glyphicon glyphicon-trash"></span>
             </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>
       </td>
       <tr>
         <td class="expand-cell" colspan="6">
           <div class="d-flex moderation-expanded">
-            <!-- report metadata -->
+            <!-- report left part (report details) -->
             <div class="col-8">
+
+              <!-- report metadata -->
               <div class="d-flex">
                 <span class="col-3 moderation-expanded-label" i18n>Reporter</span>
                 <span class="col-9 moderation-expanded-text">
                   </a>
                 </span>
               </div>
+
               <div class="d-flex">
                 <span class="col-3 moderation-expanded-label" i18n>Reportee</span>
                 <span class="col-9 moderation-expanded-text">
                   </a>
                 </span>
               </div>
+
               <div class="d-flex">
                 <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>
                 <span class="col-3 moderation-expanded-label" i18n>Report #{{ videoAbuse.id }}</span>
                 <span class="col-9 moderation-expanded-text" [innerHTML]="videoAbuse.reasonHtml"></span>
               </div>
+
               <div class="mt-3 d-flex" *ngIf="videoAbuse.moderationComment">
                 <span class="col-3 moderation-expanded-label" i18n>Note</span>
                 <span class="col-9 moderation-expanded-text" [innerHTML]="videoAbuse.moderationCommentHtml"></span>
               </div>
+
             </div>
 
+            <!-- report right part (video details) -->
             <div class="col-4">
               <div class="screenratio">
                 <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 *ngIf="!videoAbuse.video.deleted && !videoAbuse.video.blacklisted" [innerHTML]="videoAbuse.embedHtml"></div>
               </div>
index 2ece5dcc112a6ce7e7cb55d9cb7ec72fde7cfa54..f04efa9fcb4b570af6fe96b7f59135c09b308966 100644 (file)
@@ -29,8 +29,6 @@ export class VideoAbuseListComponent extends RestTable implements OnInit, AfterV
 
   videoAbuses: (VideoAbuse & { moderationCommentHtml?: string, reasonHtml?: string })[] = []
   totalRecords = 0
-  rowsPerPageOptions = [ 20, 50, 100 ]
-  rowsPerPage = this.rowsPerPageOptions[0]
   sort: SortMeta = { field: 'createdAt', order: 1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
 
@@ -199,7 +197,7 @@ export class VideoAbuseListComponent extends RestTable implements OnInit, AfterV
   }
 
   ngAfterViewInit () {
-    this.setTableFilter(this.search)
+    if (this.search) this.setTableFilter(this.search)
   }
 
   getIdentifier () {
index e9925f9bf421ac492681241a74d9691f8a6dedcc..63ecdeb9ff84d30b7eed1c697c8ced73bf347b68 100644 (file)
@@ -17,8 +17,6 @@ import { MarkdownService } from '@app/shared/renderer'
 export class VideoBlacklistListComponent extends RestTable implements OnInit {
   blacklist: (VideoBlacklist & { reasonHtml?: string })[] = []
   totalRecords = 0
-  rowsPerPageOptions = [ 20, 50, 100 ]
-  rowsPerPage = this.rowsPerPageOptions[0]
   sort: SortMeta = { field: 'createdAt', order: -1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
   listBlacklistTypeFilter: VideoBlacklistType = undefined
index dc8343b52f8f3f7076b862f21c457fa62be58b46..4f7f7c3681d638b011f4b22ebd6a0e3b649c3496 100644 (file)
@@ -40,7 +40,6 @@ export class JobsComponent extends RestTable implements OnInit {
 
   jobs: Job[] = []
   totalRecords: number
-  rowsPerPage = 10
   sort: SortMeta = { field: 'createdAt', order: -1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
 
index 667a0e1fd77a7f457dc22ce672219a946fb0cf8b..da50b7ed07f9188c6d4585bf583580e1061a76a8 100644 (file)
@@ -19,7 +19,6 @@ export class UserListComponent extends RestTable implements OnInit {
 
   users: User[] = []
   totalRecords = 0
-  rowsPerPage = 10
   sort: SortMeta = { field: 'createdAt', order: 1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
 
index d8e9fc51485539f44d2ee0a3bf05751f1d2fe151..fd1fabcdbfea284fd51baea9949d45ba80836555 100644 (file)
@@ -13,7 +13,6 @@ import { AccountBlock, BlocklistService } from '@app/shared/blocklist'
 export class MyAccountBlocklistComponent extends RestTable implements OnInit {
   blockedAccounts: AccountBlock[] = []
   totalRecords = 0
-  rowsPerPage = 10
   sort: SortMeta = { field: 'createdAt', order: -1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
 
index 9049dc69c073d7391a16f4c231b02a42e0c8887a..483c11804c032cca6b96caeb2ec504176ca12a27 100644 (file)
@@ -14,7 +14,6 @@ import { BlocklistService } from '@app/shared/blocklist'
 export class MyAccountServerBlocklistComponent extends RestTable implements OnInit {
   blockedServers: ServerBlock[] = []
   totalRecords = 0
-  rowsPerPage = 10
   sort: SortMeta = { field: 'createdAt', order: -1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
 
index 324641be16f864a0b213f90c25127d0ca51d100e..f0a6303d1cb89dd5b7870fbf23720f70aa232fdc 100644 (file)
@@ -14,7 +14,6 @@ import { MyAccountAcceptOwnershipComponent } from './my-account-accept-ownership
 export class MyAccountOwnershipComponent extends RestTable implements OnInit {
   videoChangeOwnerships: VideoChangeOwnership[] = []
   totalRecords = 0
-  rowsPerPage = 10
   sort: SortMeta = { field: 'createdAt', order: -1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
 
index 9281f978941671c8bf9e4470460541a2e48c9499..4452154ebf837deaa711410eee79ef34224cdca7 100644 (file)
@@ -2,7 +2,6 @@ import { Component, OnInit } from '@angular/core'
 import { RestPagination, RestTable } from '@app/shared'
 import { SortMeta } from 'primeng/api'
 import { Notifier } from '@app/core'
-import { I18n } from '@ngx-translate/i18n-polyfill'
 import { VideoImport, VideoImportState } from '../../../../../shared/models/videos'
 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 {
   videoImports: VideoImport[] = []
   totalRecords = 0
-  rowsPerPage = 10
   sort: SortMeta = { field: 'createdAt', order: 1 }
   pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
 
index 5954a7ba18ad49cc315c6cb8c084e6329d5b4de8..891fb7b2b3cc179d00a1f7465ce1bb7bfbdd6d90 100644 (file)
@@ -7,11 +7,13 @@ import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
 export abstract class RestTable {
 
   abstract totalRecords: number
-  abstract rowsPerPage: number
   abstract sort: SortMeta
   abstract pagination: RestPagination
 
   search: string
+  rowsPerPageOptions = [ 10, 20, 50, 100 ]
+  rowsPerPage = this.rowsPerPageOptions[0]
+
   private searchStream: Subject<string>
 
   abstract getIdentifier (): string
index 7553a5eb3355e445606ad8bcbc2cc16a76c1494f..97a5724b6dd69afd69ad3c57051896ff1af310a9 100644 (file)
@@ -7,7 +7,7 @@ async function doesVideoAbuseExist (abuseIdArg: number | string, videoUUID: stri
   let videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, null, videoUUID)
 
   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)
 
     if (video) videoAbuse = await VideoAbuseModel.loadByIdAndVideoId(abuseId, video.id)
index 26333feb5888cd5096c6481d92192518112d6ecf..610307aa489239c2d1496be5e7dd92a00560efd9 100644 (file)
@@ -11,10 +11,8 @@ async function up (utils: {
     allowNull: true
   }
   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" ADD CONSTRAINT "videoAbuse_videoId_fkey" 
-  FOREIGN KEY ("videoId") REFERENCES video(id) ON UPDATE CASCADE ON DELETE SET NULL;`)
 
 }
 
index fe2d5d010331147800195802408871c96448b0cf..d8a7ce4b4a5a6f26e62fbd91322e2a6d512f4b2c 100644 (file)
@@ -133,8 +133,8 @@ export class AccountBlocklistModel extends Model<AccountBlocklistModel> {
     if (search) {
       Object.assign(where, {
         [Op.or]: [
-          { ...searchAttribute(search, '$BlockedAccount.name$') },
-          { ...searchAttribute(search, '$BlockedAccount.Actor.url$') }
+          searchAttribute(search, '$BlockedAccount.name$'),
+          searchAttribute(search, '$BlockedAccount.Actor.url$')
         ]
       })
     }
index 764203d2c47a62eba78c69e8126f26feeed5909a..892024c04a4e074d25739bd6adf8ee80d6c9b7ed 100644 (file)
@@ -139,8 +139,6 @@ export class ServerBlocklistModel extends Model<ServerBlocklistModel> {
       }
     }
 
-    console.log(search)
-
     return ServerBlocklistModel
       .scope([ ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_SERVER ])
       .findAndCountAll<MServerBlocklistAccountServer>(query)
index 7137419a2e3d34b2543befb5e5d7012e162c06e1..bdf2291f0ceb5b34ed3c089de5e71044ec7304b8 100644 (file)
@@ -208,13 +208,15 @@ function buildDirectionAndField (value: string) {
 }
 
 function searchAttribute (sourceField, targetField) {
-  return sourceField
-    ? {
+  if (sourceField) {
+    return {
       [targetField]: {
         [Op.iLike]: `%${sourceField}%`
       }
     }
-    : {}
+  } else {
+    return {}
+  }
 }
 
 // ---------------------------------------------------------------------------
index e8c3bd8234be926693699c1474b98a514f537476..71b519cd9a2b8b6b05da709e75ce9d6a47c8e86a 100644 (file)
@@ -15,7 +15,7 @@ import { VideoAbuseState, VideoDetails } from '../../../shared'
 import { CONSTRAINTS_FIELDS, VIDEO_ABUSE_STATES } from '../../initializers/constants'
 import { MUserAccountId, MVideoAbuse, MVideoAbuseFormattable, MVideoAbuseVideo } from '../../typings/models'
 import * as Bluebird from 'bluebird'
-import { literal, Op } from 'sequelize'
+import { literal, Op, Sequelize } from 'sequelize'
 import { ThumbnailModel } from './thumbnail'
 import { VideoBlacklistModel } from './video-blacklist'
 import { ScopeNames as VideoChannelScopeNames, SummaryOptions, VideoChannelModel } from './video-channel'
@@ -31,7 +31,7 @@ export enum ScopeNames {
     searchVideo?: string
     searchVideoChannel?: string
     serverAccountId: number
-    userAccountId: any
+    userAccountId: number
   }) => {
     let where = {
       reporterAccountId: {
@@ -45,28 +45,28 @@ export enum ScopeNames {
           {
             [Op.and]: [
               { videoId: { [Op.not]: null } },
-              { '$Video.name$': { [Op.iLike]: `%${options.search}%` } }
+              searchAttribute(options.search, '$Video.name$')
             ]
           },
           {
             [Op.and]: [
               { videoId: { [Op.not]: null } },
-              { '$Video.VideoChannel.name$': { [Op.iLike]: `%${options.search}%` } }
+              searchAttribute(options.search, '$Video.VideoChannel.name$')
             ]
           },
           {
             [Op.and]: [
               { deletedVideo: { [Op.not]: null } },
-              { deletedVideo: { name: { [Op.iLike]: `%${options.search}%` } } }
+              { deletedVideo: searchAttribute(options.search, 'name') }
             ]
           },
           {
             [Op.and]: [
               { 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(
               '(' +
-                'SELECT t.count ' +
-                'FROM ( ' +
-                  'SELECT id, ' +
-                         'count(id) OVER (PARTITION BY "videoId") ' +
-                  'FROM "videoAbuse" ' +
-                ') t ' +
-                'WHERE t.id = "VideoAbuseModel".id ' +
+                'SELECT count(*) ' +
+                'FROM "videoAbuse" ' +
+                'WHERE "videoId" = "VideoAbuseModel"."videoId" ' +
               ')'
             ),
             'countReportsForVideo'
@@ -118,20 +114,11 @@ export enum ScopeNames {
           [
             literal(
               '(' +
-                'WITH ' +
-                  '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") ' +
+                'SELECT count(DISTINCT "videoAbuse"."id") ' +
                 'FROM "videoAbuse" ' +
                 'INNER JOIN "video" ON "video"."id" = "videoAbuse"."videoId" ' +
                 'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' +
-                'INNER JOIN "account" ON "videoChannel"."accountId" = "account"."id" ' +
-                'INNER JOIN ids ON "account"."id" = ids.id ' +
+                'INNER JOIN "account" ON "videoChannel"."accountId" = "Video->VideoChannel"."accountId" ' +
               ')'
             ),
             'countReportsForReportee'
@@ -142,19 +129,19 @@ export enum ScopeNames {
         {
           model: AccountModel,
           required: true,
-          where: { ...searchAttribute(options.searchReporter, 'name') }
+          where: searchAttribute(options.searchReporter, 'name')
         },
         {
           model: VideoModel,
           required: false,
-          where: { ...searchAttribute(options.searchVideo, 'name') },
+          where: searchAttribute(options.searchVideo, 'name'),
           include: [
             {
               model: ThumbnailModel
             },
             {
               model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, { withAccount: true } as SummaryOptions ] }),
-              where: { ...searchAttribute(options.searchVideoChannel, 'name') }
+              where: searchAttribute(options.searchVideoChannel, 'name')
             },
             {
               attributes: [ 'id', 'reason', 'unfederated' ],
index 680eba471e5f693c55771115e9eb27a70adf4d87..8cbfe362e87e87646df9ce4ef312b2c06fa61c63 100644 (file)
@@ -78,7 +78,7 @@ export class VideoBlacklistModel extends Model<VideoBlacklistModel> {
       {
         model: VideoModel,
         required: true,
-        where: { ...searchAttribute(search, 'name') },
+        where: searchAttribute(search, 'name'),
         include: [
           {
             model: VideoChannelModel.scope({ method: [ VideoChannelScopeNames.SUMMARY, { withAccount: true } as SummaryOptions ] }),
index f32216e908c4604d83fd7bc9d2f376bc1fb5bedb..ccb9d64ca4ad24a583429d58f75e23a5b647596e 100644 (file)
@@ -813,10 +813,8 @@ export class VideoModel extends Model<VideoModel> {
     const details = instance.toFormattedDetailsJSON()
 
     for (const abuse of instance.VideoAbuses) {
-      tasks.push((_ => {
-        abuse.deletedVideo = details
-        return abuse.save({ transaction: options.transaction })
-      })())
+      abuse.deletedVideo = details
+      tasks.push(abuse.save({ transaction: options.transaction }))
     }
 
     Promise.all(tasks)