aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-16 09:54:59 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-16 09:54:59 +0200
commit70c065d64c330196d371941d9294a55da6e3aa37 (patch)
tree4532a9611502135bedb1cc6009c706e31f1f9be4 /server/models/video/video.ts
parent74889a71fe687dda74f2a687653122327807af36 (diff)
downloadPeerTube-70c065d64c330196d371941d9294a55da6e3aa37.tar.gz
PeerTube-70c065d64c330196d371941d9294a55da6e3aa37.tar.zst
PeerTube-70c065d64c330196d371941d9294a55da6e3aa37.zip
Add this context to instance model functions
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts22
1 files changed, 11 insertions, 11 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 866b380cc..e66ebee2d 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -247,7 +247,8 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
247 loadByHostAndRemoteId, 247 loadByHostAndRemoteId,
248 loadAndPopulateAuthor, 248 loadAndPopulateAuthor,
249 loadAndPopulateAuthorAndPodAndTags, 249 loadAndPopulateAuthorAndPodAndTags,
250 searchAndPopulateAuthorAndPodAndTags 250 searchAndPopulateAuthorAndPodAndTags,
251 removeFromBlacklist
251 ] 252 ]
252 const instanceMethods = [ 253 const instanceMethods = [
253 generateMagnetUri, 254 generateMagnetUri,
@@ -260,7 +261,6 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da
260 toAddRemoteJSON, 261 toAddRemoteJSON,
261 toUpdateRemoteJSON, 262 toUpdateRemoteJSON,
262 transcodeVideofile, 263 transcodeVideofile,
263 removeFromBlacklist
264 ] 264 ]
265 addMethodsToModel(Video, classMethods, instanceMethods) 265 addMethodsToModel(Video, classMethods, instanceMethods)
266 266
@@ -389,7 +389,7 @@ function associate (models) {
389 }) 389 })
390} 390}
391 391
392generateMagnetUri = function () { 392generateMagnetUri = function (this: VideoInstance) {
393 let baseUrlHttp 393 let baseUrlHttp
394 let baseUrlWs 394 let baseUrlWs
395 395
@@ -416,18 +416,18 @@ generateMagnetUri = function () {
416 return magnetUtil.encode(magnetHash) 416 return magnetUtil.encode(magnetHash)
417} 417}
418 418
419getVideoFilename = function () { 419getVideoFilename = function (this: VideoInstance) {
420 if (this.isOwned()) return this.id + this.extname 420 if (this.isOwned()) return this.id + this.extname
421 421
422 return this.remoteId + this.extname 422 return this.remoteId + this.extname
423} 423}
424 424
425getThumbnailName = function () { 425getThumbnailName = function (this: VideoInstance) {
426 // We always have a copy of the thumbnail 426 // We always have a copy of the thumbnail
427 return this.id + '.jpg' 427 return this.id + '.jpg'
428} 428}
429 429
430getPreviewName = function () { 430getPreviewName = function (this: VideoInstance) {
431 const extension = '.jpg' 431 const extension = '.jpg'
432 432
433 if (this.isOwned()) return this.id + extension 433 if (this.isOwned()) return this.id + extension
@@ -435,7 +435,7 @@ getPreviewName = function () {
435 return this.remoteId + extension 435 return this.remoteId + extension
436} 436}
437 437
438getTorrentName = function () { 438getTorrentName = function (this: VideoInstance) {
439 const extension = '.torrent' 439 const extension = '.torrent'
440 440
441 if (this.isOwned()) return this.id + extension 441 if (this.isOwned()) return this.id + extension
@@ -443,7 +443,7 @@ getTorrentName = function () {
443 return this.remoteId + extension 443 return this.remoteId + extension
444} 444}
445 445
446isOwned = function () { 446isOwned = function (this: VideoInstance) {
447 return this.remoteId === null 447 return this.remoteId === null
448} 448}
449 449
@@ -497,7 +497,7 @@ toFormatedJSON = function (this: VideoInstance) {
497 return json 497 return json
498} 498}
499 499
500toAddRemoteJSON = function (callback: VideoMethods.ToAddRemoteJSONCallback) { 500toAddRemoteJSON = function (this: VideoInstance, callback: VideoMethods.ToAddRemoteJSONCallback) {
501 // Get thumbnail data to send to the other pod 501 // Get thumbnail data to send to the other pod
502 const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, this.getThumbnailName()) 502 const thumbnailPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, this.getThumbnailName())
503 fs.readFile(thumbnailPath, (err, thumbnailData) => { 503 fs.readFile(thumbnailPath, (err, thumbnailData) => {
@@ -531,7 +531,7 @@ toAddRemoteJSON = function (callback: VideoMethods.ToAddRemoteJSONCallback) {
531 }) 531 })
532} 532}
533 533
534toUpdateRemoteJSON = function () { 534toUpdateRemoteJSON = function (this: VideoInstance) {
535 const json = { 535 const json = {
536 name: this.name, 536 name: this.name,
537 category: this.category, 537 category: this.category,
@@ -555,7 +555,7 @@ toUpdateRemoteJSON = function () {
555 return json 555 return json
556} 556}
557 557
558transcodeVideofile = function (finalCallback: VideoMethods.TranscodeVideofileCallback) { 558transcodeVideofile = function (this: VideoInstance, finalCallback: VideoMethods.TranscodeVideofileCallback) {
559 const video = this 559 const video = this
560 560
561 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR 561 const videosDirectory = CONFIG.STORAGE.VIDEOS_DIR