]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/account/account-video-rate.ts
Fix multiple server tests
[github/Chocobozzz/PeerTube.git] / server / models / account / account-video-rate.ts
index 85af9e3782c38535cab1ed01b53e2df1d7606031..d5c214ecbc69b1a9e82395404b88b5c680642aab 100644 (file)
@@ -89,6 +89,25 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> {
     return AccountVideoRateModel.findOne(options)
   }
 
+  static loadByAccountAndVideoOrUrl (accountId: number, videoId: number, url: string, transaction?: Transaction) {
+    const options: FindOptions = {
+      where: {
+        [ Op.or]: [
+          {
+            accountId,
+            videoId
+          },
+          {
+            url
+          }
+        ]
+      }
+    }
+    if (transaction) options.transaction = transaction
+
+    return AccountVideoRateModel.findOne(options)
+  }
+
   static listByAccountForApi (options: {
     start: number,
     count: number,
@@ -202,6 +221,23 @@ export class AccountVideoRateModel extends Model<AccountVideoRateModel> {
           videoId,
           type
         },
+        include: [
+          {
+            model: AccountModel.unscoped(),
+            required: true,
+            include: [
+              {
+                model: ActorModel.unscoped(),
+                required: true,
+                where: {
+                  serverId: {
+                    [Op.ne]: null
+                  }
+                }
+              }
+            ]
+          }
+        ],
         transaction: t
       }