cache-file.ts 896 B

1234567891011121314151617181920212223242526
  1. import { isActivityPubUrlValid } from './misc'
  2. import { isRemoteVideoUrlValid } from './videos'
  3. import { exists, isDateValid } from '../misc'
  4. import { CacheFileObject } from '../../../../shared/models/activitypub/objects'
  5. function isCacheFileObjectValid (object: CacheFileObject) {
  6. return exists(object) &&
  7. object.type === 'CacheFile' &&
  8. isDateValid(object.expires) &&
  9. isActivityPubUrlValid(object.object) &&
  10. (isRemoteVideoUrlValid(object.url) || isPlaylistRedundancyUrlValid(object.url))
  11. }
  12. // ---------------------------------------------------------------------------
  13. export {
  14. isCacheFileObjectValid
  15. }
  16. // ---------------------------------------------------------------------------
  17. function isPlaylistRedundancyUrlValid (url: any) {
  18. return url.type === 'Link' &&
  19. (url.mediaType || url.mimeType) === 'application/x-mpegURL' &&
  20. isActivityPubUrlValid(url.href)
  21. }