diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-26 10:55:40 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-03-18 11:17:59 +0100 |
commit | 418d092afa81e2c8fe8ac6838fc4b5eb0af6a782 (patch) | |
tree | 5e9bc5604fd5d66a006cfebb7acdbdd5486e5d1e /server/helpers/custom-validators/activitypub/playlist.ts | |
parent | b427febb4d5cebf03b815bca2c59af6e82491569 (diff) | |
download | PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.tar.gz PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.tar.zst PeerTube-418d092afa81e2c8fe8ac6838fc4b5eb0af6a782.zip |
Playlist server API
Diffstat (limited to 'server/helpers/custom-validators/activitypub/playlist.ts')
-rw-r--r-- | server/helpers/custom-validators/activitypub/playlist.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/activitypub/playlist.ts b/server/helpers/custom-validators/activitypub/playlist.ts new file mode 100644 index 000000000..ecdc7975e --- /dev/null +++ b/server/helpers/custom-validators/activitypub/playlist.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | import { exists } from '../misc' | ||
2 | import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' | ||
3 | import * as validator from 'validator' | ||
4 | import { PlaylistElementObject } from '../../../../shared/models/activitypub/objects/playlist-element-object' | ||
5 | import { isActivityPubUrlValid } from './misc' | ||
6 | |||
7 | function isPlaylistObjectValid (object: PlaylistObject) { | ||
8 | return exists(object) && | ||
9 | object.type === 'Playlist' && | ||
10 | validator.isInt(object.totalItems + '') | ||
11 | } | ||
12 | |||
13 | function isPlaylistElementObjectValid (object: PlaylistElementObject) { | ||
14 | return exists(object) && | ||
15 | object.type === 'PlaylistElement' && | ||
16 | validator.isInt(object.position + '') && | ||
17 | isActivityPubUrlValid(object.url) | ||
18 | } | ||
19 | |||
20 | // --------------------------------------------------------------------------- | ||
21 | |||
22 | export { | ||
23 | isPlaylistObjectValid, | ||
24 | isPlaylistElementObjectValid | ||
25 | } | ||