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'
8 async function createWatchLaterPlaylist (account: AccountModel, t: Sequelize.Transaction) {
9 const videoPlaylist = new VideoPlaylistModel({
11 privacy: VideoPlaylistPrivacy.PRIVATE,
12 type: VideoPlaylistType.WATCH_LATER,
13 ownerAccountId: account.id
16 videoPlaylist.url = getVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object
18 await videoPlaylist.save({ transaction: t })
20 videoPlaylist.OwnerAccount = account
25 // ---------------------------------------------------------------------------
28 createWatchLaterPlaylist