playlist.ts 949 B

123456789101112131415161718192021222324252627
  1. import { exists, isDateValid } from '../misc'
  2. import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
  3. import * as validator from 'validator'
  4. import { PlaylistElementObject } from '../../../../shared/models/activitypub/objects/playlist-element-object'
  5. import { isActivityPubUrlValid } from './misc'
  6. function isPlaylistObjectValid (object: PlaylistObject) {
  7. return exists(object) &&
  8. object.type === 'Playlist' &&
  9. validator.isInt(object.totalItems + '') &&
  10. isDateValid(object.published) &&
  11. isDateValid(object.updated)
  12. }
  13. function isPlaylistElementObjectValid (object: PlaylistElementObject) {
  14. return exists(object) &&
  15. object.type === 'PlaylistElement' &&
  16. validator.isInt(object.position + '') &&
  17. isActivityPubUrlValid(object.url)
  18. }
  19. // ---------------------------------------------------------------------------
  20. export {
  21. isPlaylistObjectValid,
  22. isPlaylistElementObjectValid
  23. }