video-playlist.ts 1.1 KB

123456789101112131415161718192021222324252627282930
  1. import * as Sequelize from 'sequelize'
  2. import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model'
  3. import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model'
  4. import { VideoPlaylistModel } from '../models/video/video-playlist'
  5. import { MAccount } from '../types/models'
  6. import { MVideoPlaylistOwner } from '../types/models/video/video-playlist'
  7. import { getLocalVideoPlaylistActivityPubUrl } from './activitypub/url'
  8. async function createWatchLaterPlaylist (account: MAccount, t: Sequelize.Transaction) {
  9. const videoPlaylist: MVideoPlaylistOwner = new VideoPlaylistModel({
  10. name: 'Watch later',
  11. privacy: VideoPlaylistPrivacy.PRIVATE,
  12. type: VideoPlaylistType.WATCH_LATER,
  13. ownerAccountId: account.id
  14. })
  15. videoPlaylist.url = getLocalVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object
  16. await videoPlaylist.save({ transaction: t })
  17. videoPlaylist.OwnerAccount = account
  18. return videoPlaylist
  19. }
  20. // ---------------------------------------------------------------------------
  21. export {
  22. createWatchLaterPlaylist
  23. }