From 1297eb5db651a230474670c5da1517862fb9cc3e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 22 Aug 2018 16:15:35 +0200 Subject: Add refresh video on search --- server/models/video/video.ts | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'server/models') 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 import { logger } from '../../helpers/logger' import { getServerActor } from '../../helpers/utils' import { + ACTIVITY_PUB, API_VERSION, CONFIG, CONSTRAINTS_FIELDS, @@ -1004,21 +1005,6 @@ export class VideoModel extends Model { return VideoModel.scope([ ScopeNames.WITH_ACCOUNT_DETAILS, ScopeNames.WITH_FILES ]).findOne(query) } - static loadByUUIDOrURLAndPopulateAccount (uuid: string, url: string, t?: Sequelize.Transaction) { - const query: IFindOptions = { - where: { - [Sequelize.Op.or]: [ - { uuid }, - { url } - ] - } - } - - if (t !== undefined) query.transaction = t - - return VideoModel.scope([ ScopeNames.WITH_ACCOUNT_DETAILS, ScopeNames.WITH_FILES ]).findOne(query) - } - static loadAndPopulateAccountAndServerAndTags (id: number) { const options = { order: [ [ 'Tags', 'name', 'ASC' ] ] @@ -1646,6 +1632,17 @@ export class VideoModel extends Model { return 'PT' + this.duration + 'S' } + isOutdated () { + if (this.isOwned()) return false + + const now = Date.now() + const createdAtTime = this.createdAt.getTime() + const updatedAtTime = this.updatedAt.getTime() + + return (now - createdAtTime) > ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL && + (now - updatedAtTime) > ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL + } + private getBaseUrls () { let baseUrlHttp let baseUrlWs -- cgit v1.2.3