2019-03-05 10:58:44 +01:00
|
|
|
import * as Sequelize from 'sequelize'
|
|
|
|
import { VideoPlaylistModel } from '../models/video/video-playlist'
|
|
|
|
import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model'
|
2020-04-23 09:32:53 +02:00
|
|
|
import { getVideoPlaylistActivityPubUrl } from './activitypub/url'
|
2019-03-05 10:58:44 +01:00
|
|
|
import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model'
|
2019-08-15 11:53:26 +02:00
|
|
|
import { MAccount } from '../typings/models'
|
|
|
|
import { MVideoPlaylistOwner } from '../typings/models/video/video-playlist'
|
2019-03-05 10:58:44 +01:00
|
|
|
|
2019-08-15 11:53:26 +02:00
|
|
|
async function createWatchLaterPlaylist (account: MAccount, t: Sequelize.Transaction) {
|
|
|
|
const videoPlaylist: MVideoPlaylistOwner = new VideoPlaylistModel({
|
2019-03-05 10:58:44 +01:00
|
|
|
name: 'Watch later',
|
|
|
|
privacy: VideoPlaylistPrivacy.PRIVATE,
|
|
|
|
type: VideoPlaylistType.WATCH_LATER,
|
|
|
|
ownerAccountId: account.id
|
|
|
|
})
|
|
|
|
|
|
|
|
videoPlaylist.url = getVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object
|
|
|
|
|
|
|
|
await videoPlaylist.save({ transaction: t })
|
|
|
|
|
|
|
|
videoPlaylist.OwnerAccount = account
|
|
|
|
|
|
|
|
return videoPlaylist
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
createWatchLaterPlaylist
|
|
|
|
}
|