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