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'
9 async function createWatchLaterPlaylist (account: MAccount, t: Sequelize.Transaction) {
10 const videoPlaylist: MVideoPlaylistOwner = new VideoPlaylistModel({
12 privacy: VideoPlaylistPrivacy.PRIVATE,
13 type: VideoPlaylistType.WATCH_LATER,
14 ownerAccountId: account.id
17 videoPlaylist.url = getLocalVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object
19 await videoPlaylist.save({ transaction: t })
21 videoPlaylist.OwnerAccount = account
26 // ---------------------------------------------------------------------------
29 createWatchLaterPlaylist