2019-01-15 11:14:12 +01:00
|
|
|
import { isActivityPubUrlValid } from './misc'
|
2018-09-11 16:27:07 +02:00
|
|
|
import { isRemoteVideoUrlValid } from './videos'
|
2019-01-15 11:14:12 +01:00
|
|
|
import { exists, isDateValid } from '../misc'
|
2018-09-11 16:27:07 +02:00
|
|
|
import { CacheFileObject } from '../../../../shared/models/activitypub/objects'
|
|
|
|
|
|
|
|
function isCacheFileObjectValid (object: CacheFileObject) {
|
|
|
|
return exists(object) &&
|
|
|
|
object.type === 'CacheFile' &&
|
|
|
|
isDateValid(object.expires) &&
|
|
|
|
isActivityPubUrlValid(object.object) &&
|
2019-01-29 08:37:25 +01:00
|
|
|
(isRemoteVideoUrlValid(object.url) || isPlaylistRedundancyUrlValid(object.url))
|
2018-09-11 16:27:07 +02:00
|
|
|
}
|
|
|
|
|
2019-01-29 08:37:25 +01:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2018-09-11 16:27:07 +02:00
|
|
|
export {
|
|
|
|
isCacheFileObjectValid
|
|
|
|
}
|
2019-01-29 08:37:25 +01:00
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
function isPlaylistRedundancyUrlValid (url: any) {
|
|
|
|
return url.type === 'Link' &&
|
|
|
|
(url.mediaType || url.mimeType) === 'application/x-mpegURL' &&
|
|
|
|
isActivityPubUrlValid(url.href)
|
|
|
|
}
|