video-playlist.ts 1.1 KB

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