diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-05 10:58:44 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-03-18 11:17:59 +0100 |
commit | df0b219d36bf6852cdf2a7ad09ed4a41c6bccefa (patch) | |
tree | c4984e854f5dc18e5c27afd73b843bd52c143034 /server/lib/video-playlist.ts | |
parent | 07b1a18aa678d260009a93e36606c5c5f585723d (diff) | |
download | PeerTube-df0b219d36bf6852cdf2a7ad09ed4a41c6bccefa.tar.gz PeerTube-df0b219d36bf6852cdf2a7ad09ed4a41c6bccefa.tar.zst PeerTube-df0b219d36bf6852cdf2a7ad09ed4a41c6bccefa.zip |
Add playlist rest tests
Diffstat (limited to 'server/lib/video-playlist.ts')
-rw-r--r-- | server/lib/video-playlist.ts | 29 |
1 files changed, 29 insertions, 0 deletions
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 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { AccountModel } from '../models/account/account' | ||
3 | import { VideoPlaylistModel } from '../models/video/video-playlist' | ||
4 | import { VideoPlaylistPrivacy } from '../../shared/models/videos/playlist/video-playlist-privacy.model' | ||
5 | import { getVideoPlaylistActivityPubUrl } from './activitypub' | ||
6 | import { VideoPlaylistType } from '../../shared/models/videos/playlist/video-playlist-type.model' | ||
7 | |||
8 | async function createWatchLaterPlaylist (account: AccountModel, t: Sequelize.Transaction) { | ||
9 | const videoPlaylist = new VideoPlaylistModel({ | ||
10 | name: 'Watch later', | ||
11 | privacy: VideoPlaylistPrivacy.PRIVATE, | ||
12 | type: VideoPlaylistType.WATCH_LATER, | ||
13 | ownerAccountId: account.id | ||
14 | }) | ||
15 | |||
16 | videoPlaylist.url = getVideoPlaylistActivityPubUrl(videoPlaylist) // We use the UUID, so set the URL after building the object | ||
17 | |||
18 | await videoPlaylist.save({ transaction: t }) | ||
19 | |||
20 | videoPlaylist.OwnerAccount = account | ||
21 | |||
22 | return videoPlaylist | ||
23 | } | ||
24 | |||
25 | // --------------------------------------------------------------------------- | ||
26 | |||
27 | export { | ||
28 | createWatchLaterPlaylist | ||
29 | } | ||