]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/lib/video-playlist.ts
feature/ability to disable video history by default (#5728)
[github/Chocobozzz/PeerTube.git] / server / lib / video-playlist.ts
CommitLineData
df0b219d 1import * as Sequelize from 'sequelize'
df0b219d 2import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model'
df0b219d 3import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model'
de94ac86 4import { VideoPlaylistModel } from '../models/video/video-playlist'
26d6bf65
C
5import { MAccount } from '../types/models'
6import { MVideoPlaylistOwner } from '../types/models/video/video-playlist'
de94ac86 7import { getLocalVideoPlaylistActivityPubUrl } from './activitypub/url'
df0b219d 8
453e83ea
C
9async function createWatchLaterPlaylist (account: MAccount, t: Sequelize.Transaction) {
10 const videoPlaylist: MVideoPlaylistOwner = new VideoPlaylistModel({
df0b219d
C
11 name: 'Watch later',
12 privacy: VideoPlaylistPrivacy.PRIVATE,
13 type: VideoPlaylistType.WATCH_LATER,
14 ownerAccountId: account.id
15 })
16
de94ac86 17 videoPlaylist.url = getLocalVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object
df0b219d
C
18
19 await videoPlaylist.save({ transaction: t })
20
21 videoPlaylist.OwnerAccount = account
22
23 return videoPlaylist
24}
25
26// ---------------------------------------------------------------------------
27
28export {
29 createWatchLaterPlaylist
30}