]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/oauth-client.js
Server: add video abuse support
[github/Chocobozzz/PeerTube.git] / server / models / oauth-client.js
index b56838d4c9918126a35b82c2f38d52caf5c77eb9..021a3400752d50e6ab427852b21c294676ac7da8 100644 (file)
@@ -19,11 +19,19 @@ module.exports = function (sequelize, DataTypes) {
       }
     },
     {
+      indexes: [
+        {
+          fields: [ 'clientId' ],
+          unique: true
+        },
+        {
+          fields: [ 'clientId', 'clientSecret' ],
+          unique: true
+        }
+      ],
       classMethods: {
-        associate,
-
+        countTotal,
         getByIdAndSecret,
-        list,
         loadFirstClient
       }
     }
@@ -34,18 +42,8 @@ module.exports = function (sequelize, DataTypes) {
 
 // ---------------------------------------------------------------------------
 
-function associate (models) {
-  this.hasMany(models.OAuthToken, {
-    foreignKey: {
-      name: 'oAuthClientId',
-      allowNull: false
-    },
-    onDelete: 'cascade'
-  })
-}
-
-function list (callback) {
-  return this.findAll().asCallback(callback)
+function countTotal (callback) {
+  return this.count().asCallback(callback)
 }
 
 function loadFirstClient (callback) {