diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-21 15:51:30 +0200 |
commit | a24bd1ed41b43790bab6ba789580bb4e85f07d85 (patch) | |
tree | a54b0f6c921ba83a6e909cd0ced325b2d4b8863c /shared/extra-utils/feeds/feeds-command.ts | |
parent | 5f26f13b3c16ac5ae0a3b0a7142d84a9528cf565 (diff) | |
parent | c63830f15403ac4e750829f27d8bbbdc9a59282c (diff) | |
download | PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.gz PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.tar.zst PeerTube-a24bd1ed41b43790bab6ba789580bb4e85f07d85.zip |
Merge branch 'next' into develop
Diffstat (limited to 'shared/extra-utils/feeds/feeds-command.ts')
-rw-r--r-- | shared/extra-utils/feeds/feeds-command.ts | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/shared/extra-utils/feeds/feeds-command.ts b/shared/extra-utils/feeds/feeds-command.ts new file mode 100644 index 000000000..3c95f9536 --- /dev/null +++ b/shared/extra-utils/feeds/feeds-command.ts | |||
@@ -0,0 +1,44 @@ | |||
1 | |||
2 | import { HttpStatusCode } from '@shared/models' | ||
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
4 | |||
5 | type FeedType = 'videos' | 'video-comments' | 'subscriptions' | ||
6 | |||
7 | export class FeedCommand extends AbstractCommand { | ||
8 | |||
9 | getXML (options: OverrideCommandOptions & { | ||
10 | feed: FeedType | ||
11 | format?: string | ||
12 | }) { | ||
13 | const { feed, format } = options | ||
14 | const path = '/feeds/' + feed + '.xml' | ||
15 | |||
16 | return this.getRequestText({ | ||
17 | ...options, | ||
18 | |||
19 | path, | ||
20 | query: format ? { format } : undefined, | ||
21 | accept: 'application/xml', | ||
22 | implicitToken: false, | ||
23 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
24 | }) | ||
25 | } | ||
26 | |||
27 | getJSON (options: OverrideCommandOptions & { | ||
28 | feed: FeedType | ||
29 | query?: { [ id: string ]: any } | ||
30 | }) { | ||
31 | const { feed, query } = options | ||
32 | const path = '/feeds/' + feed + '.json' | ||
33 | |||
34 | return this.getRequestText({ | ||
35 | ...options, | ||
36 | |||
37 | path, | ||
38 | query, | ||
39 | accept: 'application/json', | ||
40 | implicitToken: false, | ||
41 | defaultExpectedStatus: HttpStatusCode.OK_200 | ||
42 | }) | ||
43 | } | ||
44 | } | ||