From df0b219d36bf6852cdf2a7ad09ed4a41c6bccefa Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 5 Mar 2019 10:58:44 +0100 Subject: Add playlist rest tests --- server/lib/video-playlist.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 server/lib/video-playlist.ts (limited to 'server/lib/video-playlist.ts') diff --git a/server/lib/video-playlist.ts b/server/lib/video-playlist.ts new file mode 100644 index 000000000..6e214e60f --- /dev/null +++ b/server/lib/video-playlist.ts @@ -0,0 +1,29 @@ +import * as Sequelize from 'sequelize' +import { AccountModel } from '../models/account/account' +import { VideoPlaylistModel } from '../models/video/video-playlist' +import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' +import { getVideoPlaylistActivityPubUrl } from './activitypub' +import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' + +async function createWatchLaterPlaylist (account: AccountModel, t: Sequelize.Transaction) { + const videoPlaylist = new VideoPlaylistModel({ + 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 +} -- cgit v1.2.3