]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-share.ts
Add federation to ownership change
[github/Chocobozzz/PeerTube.git] / server / models / video / video-share.ts
index 6f770957faab736814a94baba94ed0e92a8d19fe..fa9a70d509b42fccb99a59e8a10b9139a91f8b15 100644 (file)
@@ -98,6 +98,15 @@ export class VideoShareModel extends Model<VideoShareModel> {
     })
   }
 
+  static loadByUrl (url: string, t: Sequelize.Transaction) {
+    return VideoShareModel.scope(ScopeNames.FULL).findOne({
+      where: {
+        url
+      },
+      transaction: t
+    })
+  }
+
   static loadActorsByShare (videoId: number, t: Sequelize.Transaction) {
     const query = {
       where: {
@@ -178,4 +187,17 @@ export class VideoShareModel extends Model<VideoShareModel> {
       .findAll(query)
       .then(res => res.map(r => r.Actor))
   }
+
+  static listAndCountByVideoId (videoId: number, start: number, count: number, t?: Sequelize.Transaction) {
+    const query = {
+      offset: start,
+      limit: count,
+      where: {
+        videoId
+      },
+      transaction: t
+    }
+
+    return VideoShareModel.findAndCountAll(query)
+  }
 }