aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-22 16:15:35 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 09:41:54 +0200
commit1297eb5db651a230474670c5da1517862fb9cc3e (patch)
treeecad4a0ceb0bb09e3c775262691ac68e9e0aca0c /server/models
parentf6eebcb336c067e160a62020a5140d8d992ba384 (diff)
downloadPeerTube-1297eb5db651a230474670c5da1517862fb9cc3e.tar.gz
PeerTube-1297eb5db651a230474670c5da1517862fb9cc3e.tar.zst
PeerTube-1297eb5db651a230474670c5da1517862fb9cc3e.zip
Add refresh video on search
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video.ts27
1 files changed, 12 insertions, 15 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 25a1cd177..7acbc60f7 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -56,6 +56,7 @@ import { generateImageFromVideoFile, getVideoFileFPS, getVideoFileResolution, tr
56import { logger } from '../../helpers/logger' 56import { logger } from '../../helpers/logger'
57import { getServerActor } from '../../helpers/utils' 57import { getServerActor } from '../../helpers/utils'
58import { 58import {
59 ACTIVITY_PUB,
59 API_VERSION, 60 API_VERSION,
60 CONFIG, 61 CONFIG,
61 CONSTRAINTS_FIELDS, 62 CONSTRAINTS_FIELDS,
@@ -1004,21 +1005,6 @@ export class VideoModel extends Model<VideoModel> {
1004 return VideoModel.scope([ ScopeNames.WITH_ACCOUNT_DETAILS, ScopeNames.WITH_FILES ]).findOne(query) 1005 return VideoModel.scope([ ScopeNames.WITH_ACCOUNT_DETAILS, ScopeNames.WITH_FILES ]).findOne(query)
1005 } 1006 }
1006 1007
1007 static loadByUUIDOrURLAndPopulateAccount (uuid: string, url: string, t?: Sequelize.Transaction) {
1008 const query: IFindOptions<VideoModel> = {
1009 where: {
1010 [Sequelize.Op.or]: [
1011 { uuid },
1012 { url }
1013 ]
1014 }
1015 }
1016
1017 if (t !== undefined) query.transaction = t
1018
1019 return VideoModel.scope([ ScopeNames.WITH_ACCOUNT_DETAILS, ScopeNames.WITH_FILES ]).findOne(query)
1020 }
1021
1022 static loadAndPopulateAccountAndServerAndTags (id: number) { 1008 static loadAndPopulateAccountAndServerAndTags (id: number) {
1023 const options = { 1009 const options = {
1024 order: [ [ 'Tags', 'name', 'ASC' ] ] 1010 order: [ [ 'Tags', 'name', 'ASC' ] ]
@@ -1646,6 +1632,17 @@ export class VideoModel extends Model<VideoModel> {
1646 return 'PT' + this.duration + 'S' 1632 return 'PT' + this.duration + 'S'
1647 } 1633 }
1648 1634
1635 isOutdated () {
1636 if (this.isOwned()) return false
1637
1638 const now = Date.now()
1639 const createdAtTime = this.createdAt.getTime()
1640 const updatedAtTime = this.updatedAt.getTime()
1641
1642 return (now - createdAtTime) > ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL &&
1643 (now - updatedAtTime) > ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL
1644 }
1645
1649 private getBaseUrls () { 1646 private getBaseUrls () {
1650 let baseUrlHttp 1647 let baseUrlHttp
1651 let baseUrlWs 1648 let baseUrlWs