]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-abuse.ts
Use global uuid instead of remoteId for videos
[github/Chocobozzz/PeerTube.git] / server / models / video / video-abuse.ts
index f5b4debe6964ad1a2b01e21031532692e23f2719..f55a25e6a16bc7d8cce7fb70f5ba8509e6ef5cfa 100644 (file)
@@ -5,7 +5,6 @@ import { isVideoAbuseReporterUsernameValid, isVideoAbuseReasonValid } from '../.
 
 import { addMethodsToModel, getSort } from '../utils'
 import {
-  VideoAbuseClass,
   VideoAbuseInstance,
   VideoAbuseAttributes,
 
@@ -13,6 +12,7 @@ import {
 } from './video-abuse-interface'
 
 let VideoAbuse: Sequelize.Model<VideoAbuseInstance, VideoAbuseAttributes>
+let toFormatedJSON: VideoAbuseMethods.ToFormatedJSON
 let listForApi: VideoAbuseMethods.ListForApi
 
 export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
@@ -66,7 +66,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
 
 // ------------------------------ METHODS ------------------------------
 
-function toFormatedJSON (this: VideoAbuseInstance) {
+toFormatedJSON = function (this: VideoAbuseInstance) {
   let reporterPodHost
 
   if (this.Pod) {
@@ -96,7 +96,7 @@ function associate (models) {
       name: 'reporterPodId',
       allowNull: true
     },
-    onDelete: 'cascade'
+    onDelete: 'CASCADE'
   })
 
   VideoAbuse.belongsTo(models.Video, {
@@ -104,11 +104,11 @@ function associate (models) {
       name: 'videoId',
       allowNull: false
     },
-    onDelete: 'cascade'
+    onDelete: 'CASCADE'
   })
 }
 
-listForApi = function (start, count, sort, callback) {
+listForApi = function (start: number, count: number, sort: string) {
   const query = {
     offset: start,
     limit: count,
@@ -121,11 +121,7 @@ listForApi = function (start, count, sort, callback) {
     ]
   }
 
-  return VideoAbuse.findAndCountAll(query).asCallback(function (err, result) {
-    if (err) return callback(err)
-
-    return callback(null, result.rows, result.count)
+  return VideoAbuse.findAndCountAll(query).then(({ rows, count }) => {
+    return { total: count, data: rows }
   })
 }
-
-