]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/video/video-playlist.ts
Add user adminFlags
[github/Chocobozzz/PeerTube.git] / server / models / video / video-playlist.ts
index 7dbe4ce8d3cf61b9b7949619e95290bb9ba09b59..0725b752a9432e22ceacfd54e421bda535d36874 100644 (file)
@@ -17,7 +17,7 @@ import {
 } from 'sequelize-typescript'
 import * as Sequelize from 'sequelize'
 import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
-import { buildServerIdsFollowedBy, buildWhereIdOrUUID, getSort, throwIfNotValid } from '../utils'
+import { buildServerIdsFollowedBy, buildWhereIdOrUUID, getSort, isOutdated, throwIfNotValid } from '../utils'
 import {
   isVideoPlaylistDescriptionValid,
   isVideoPlaylistNameValid,
@@ -25,13 +25,14 @@ import {
 } from '../../helpers/custom-validators/video-playlists'
 import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
 import {
-  CONFIG,
+  ACTIVITY_PUB,
   CONSTRAINTS_FIELDS,
   STATIC_PATHS,
   THUMBNAILS_SIZE,
   VIDEO_PLAYLIST_PRIVACIES,
-  VIDEO_PLAYLIST_TYPES
-} from '../../initializers'
+  VIDEO_PLAYLIST_TYPES,
+  WEBSERVER
+} from '../../initializers/constants'
 import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model'
 import { AccountModel, ScopeNames as AccountScopeNames } from '../account/account'
 import { ScopeNames as VideoChannelScopeNames, VideoChannelModel } from './video-channel'
@@ -42,6 +43,7 @@ import { activityPubCollectionPagination } from '../../helpers/activitypub'
 import { remove } from 'fs-extra'
 import { logger } from '../../helpers/logger'
 import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video-playlist-type.model'
+import { CONFIG } from '../../initializers/config'
 
 enum ScopeNames {
   AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST',
@@ -416,7 +418,7 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
   }
 
   getThumbnailUrl () {
-    return CONFIG.WEBSERVER.URL + STATIC_PATHS.THUMBNAILS + this.getThumbnailName()
+    return WEBSERVER.URL + STATIC_PATHS.THUMBNAILS + this.getThumbnailName()
   }
 
   getThumbnailStaticPath () {
@@ -429,10 +431,22 @@ export class VideoPlaylistModel extends Model<VideoPlaylistModel> {
       .catch(err => logger.warn('Cannot delete thumbnail %s.', thumbnailPath, { err }))
   }
 
+  setAsRefreshed () {
+    this.changed('updatedAt', true)
+
+    return this.save()
+  }
+
   isOwned () {
     return this.OwnerAccount.isOwned()
   }
 
+  isOutdated () {
+    if (this.isOwned()) return false
+
+    return isOutdated(this, ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL)
+  }
+
   toFormattedJSON (): VideoPlaylist {
     return {
       id: this.id,