aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
authorbuoyantair <buoyantair@protonmail.com>2018-11-18 21:55:52 +0530
committerbuoyantair <buoyantair@protonmail.com>2018-11-18 21:55:52 +0530
commitb9f234371bfaf0d9cfa81e02fcea92cac1f9ae13 (patch)
treedcdf451ac431ec7953bee58e814f642d1c370d1b /server/models/video
parent92e07c3b5d9dbf2febedb1b5b87ec676eb6d1ac8 (diff)
parent9d0b856e930ee1c676d16a56408a3e4a18f8f978 (diff)
downloadPeerTube-b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13.tar.gz
PeerTube-b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13.tar.zst
PeerTube-b9f234371bfaf0d9cfa81e02fcea92cac1f9ae13.zip
Merge branch 'develop' of https://github.com/Chocobozzz/PeerTube into move-utils-to-shared
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 6c183933b..1e68b380c 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1253,6 +1253,23 @@ export class VideoModel extends Model<VideoModel> {
1253 }) 1253 })
1254 } 1254 }
1255 1255
1256 static checkVideoHasInstanceFollow (videoId: number, followerActorId: number) {
1257 // Instances only share videos
1258 const query = 'SELECT 1 FROM "videoShare" ' +
1259 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "videoShare"."actorId" ' +
1260 'WHERE "actorFollow"."actorId" = $followerActorId AND "videoShare"."videoId" = $videoId ' +
1261 'LIMIT 1'
1262
1263 const options = {
1264 type: Sequelize.QueryTypes.SELECT,
1265 bind: { followerActorId, videoId },
1266 raw: true
1267 }
1268
1269 return VideoModel.sequelize.query(query, options)
1270 .then(results => results.length === 1)
1271 }
1272
1256 // threshold corresponds to how many video the field should have to be returned 1273 // threshold corresponds to how many video the field should have to be returned
1257 static async getRandomFieldSamples (field: 'category' | 'channelId', threshold: number, count: number) { 1274 static async getRandomFieldSamples (field: 'category' | 'channelId', threshold: number, count: number) {
1258 const serverActor = await getServerActor() 1275 const serverActor = await getServerActor()