aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-14 11:00:03 +0200
committerChocobozzz <me@florianbigard.com>2018-08-14 11:00:03 +0200
commitcc43831a90ab8b1b460cd7021c100190049ec64b (patch)
tree187f3602fd8749b66d5782174ba48f8a33453d7d /server/models/video
parent08c11bec43987364e83246e4e76958f5ccf89fe8 (diff)
downloadPeerTube-cc43831a90ab8b1b460cd7021c100190049ec64b.tar.gz
PeerTube-cc43831a90ab8b1b460cd7021c100190049ec64b.tar.zst
PeerTube-cc43831a90ab8b1b460cd7021c100190049ec64b.zip
Filter tracker based on infohash
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video-file.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index f5a2b6c1f..3bc4855f3 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -9,6 +9,7 @@ import {
9import { CONSTRAINTS_FIELDS } from '../../initializers' 9import { CONSTRAINTS_FIELDS } from '../../initializers'
10import { throwIfNotValid } from '../utils' 10import { throwIfNotValid } from '../utils'
11import { VideoModel } from './video' 11import { VideoModel } from './video'
12import * as Sequelize from 'sequelize'
12 13
13@Table({ 14@Table({
14 tableName: 'videoFile', 15 tableName: 'videoFile',
@@ -68,4 +69,18 @@ export class VideoFileModel extends Model<VideoFileModel> {
68 onDelete: 'CASCADE' 69 onDelete: 'CASCADE'
69 }) 70 })
70 Video: VideoModel 71 Video: VideoModel
72
73 static isInfohashExists (infoHash: string) {
74 const query = 'SELECT 1 FROM "videoFile" WHERE "infoHash" = $infoHash LIMIT 1'
75 const options = {
76 type: Sequelize.QueryTypes.SELECT,
77 bind: { infoHash },
78 raw: true
79 }
80
81 return VideoModel.sequelize.query(query, options)
82 .then(results => {
83 return results.length === 1
84 })
85 }
71} 86}