diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-16 10:42:24 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea (patch) | |
tree | baf29753ac5d4598643e3bee719f8df0cc36c59d /shared/extra-utils/users | |
parent | 08642a765ea514a00f159db898edf14c376fbe6c (diff) | |
download | PeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.tar.gz PeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.tar.zst PeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.zip |
Refactor requests
Diffstat (limited to 'shared/extra-utils/users')
-rw-r--r-- | shared/extra-utils/users/accounts-command.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/users/blocklist-command.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/users/index.ts | 1 | ||||
-rw-r--r-- | shared/extra-utils/users/login-command.ts | 10 | ||||
-rw-r--r-- | shared/extra-utils/users/notifications-command.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/users/subscriptions-command.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/users/users-command.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/users/users.ts | 20 |
8 files changed, 10 insertions, 31 deletions
diff --git a/shared/extra-utils/users/accounts-command.ts b/shared/extra-utils/users/accounts-command.ts index 4cd1d2158..08977e58b 100644 --- a/shared/extra-utils/users/accounts-command.ts +++ b/shared/extra-utils/users/accounts-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ResultList } from '@shared/models' | 1 | import { ResultList } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { Account } from '../../models/actors' | 3 | import { Account } from '../../models/actors' |
4 | import { AccountVideoRate, VideoRateType } from '../../models/videos' | 4 | import { AccountVideoRate, VideoRateType } from '../../models/videos' |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
diff --git a/shared/extra-utils/users/blocklist-command.ts b/shared/extra-utils/users/blocklist-command.ts index 089b5a579..a9431acf3 100644 --- a/shared/extra-utils/users/blocklist-command.ts +++ b/shared/extra-utils/users/blocklist-command.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import { HttpStatusCode } from '@shared/core-utils' | 3 | import { HttpStatusCode } from '@shared/models' |
4 | import { AccountBlock, ResultList, ServerBlock } from '@shared/models' | 4 | import { AccountBlock, ResultList, ServerBlock } from '@shared/models' |
5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 5 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
6 | 6 | ||
diff --git a/shared/extra-utils/users/index.ts b/shared/extra-utils/users/index.ts index e6107afa5..fbb454e8f 100644 --- a/shared/extra-utils/users/index.ts +++ b/shared/extra-utils/users/index.ts | |||
@@ -7,4 +7,3 @@ export * from './notifications' | |||
7 | export * from './notifications-command' | 7 | export * from './notifications-command' |
8 | export * from './subscriptions-command' | 8 | export * from './subscriptions-command' |
9 | export * from './users-command' | 9 | export * from './users-command' |
10 | export * from './users' | ||
diff --git a/shared/extra-utils/users/login-command.ts b/shared/extra-utils/users/login-command.ts index 10c3db851..b39577260 100644 --- a/shared/extra-utils/users/login-command.ts +++ b/shared/extra-utils/users/login-command.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { HttpStatusCode } from '@shared/core-utils' | 1 | import { HttpStatusCode } from '@shared/models' |
2 | import { PeerTubeProblemDocument } from '@shared/models' | 2 | import { PeerTubeProblemDocument } from '@shared/models' |
3 | import { unwrapBody } from '../requests' | 3 | import { unwrapBody } from '../requests' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
@@ -26,7 +26,7 @@ export class LoginCommand extends AbstractCommand { | |||
26 | ...options, | 26 | ...options, |
27 | 27 | ||
28 | path, | 28 | path, |
29 | type: 'form', | 29 | requestType: 'form', |
30 | fields: body, | 30 | fields: body, |
31 | implicitToken: false, | 31 | implicitToken: false, |
32 | defaultExpectedStatus: HttpStatusCode.OK_200 | 32 | defaultExpectedStatus: HttpStatusCode.OK_200 |
@@ -72,7 +72,7 @@ export class LoginCommand extends AbstractCommand { | |||
72 | ...options, | 72 | ...options, |
73 | 73 | ||
74 | path, | 74 | path, |
75 | type: 'form', | 75 | requestType: 'form', |
76 | fields: body, | 76 | fields: body, |
77 | implicitToken: false, | 77 | implicitToken: false, |
78 | defaultExpectedStatus: HttpStatusCode.OK_200 | 78 | defaultExpectedStatus: HttpStatusCode.OK_200 |
@@ -88,7 +88,7 @@ export class LoginCommand extends AbstractCommand { | |||
88 | ...options, | 88 | ...options, |
89 | 89 | ||
90 | path, | 90 | path, |
91 | type: 'form', | 91 | requestType: 'form', |
92 | implicitToken: false, | 92 | implicitToken: false, |
93 | defaultExpectedStatus: HttpStatusCode.OK_200 | 93 | defaultExpectedStatus: HttpStatusCode.OK_200 |
94 | })) | 94 | })) |
@@ -111,7 +111,7 @@ export class LoginCommand extends AbstractCommand { | |||
111 | ...options, | 111 | ...options, |
112 | 112 | ||
113 | path, | 113 | path, |
114 | type: 'form', | 114 | requestType: 'form', |
115 | fields: body, | 115 | fields: body, |
116 | implicitToken: false, | 116 | implicitToken: false, |
117 | defaultExpectedStatus: HttpStatusCode.OK_200 | 117 | defaultExpectedStatus: HttpStatusCode.OK_200 |
diff --git a/shared/extra-utils/users/notifications-command.ts b/shared/extra-utils/users/notifications-command.ts index dfe574ca1..a51fcc3af 100644 --- a/shared/extra-utils/users/notifications-command.ts +++ b/shared/extra-utils/users/notifications-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ResultList } from '@shared/models' | 1 | import { ResultList } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { UserNotification, UserNotificationSetting } from '../../models/users' | 3 | import { UserNotification, UserNotificationSetting } from '../../models/users' |
4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 4 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
5 | 5 | ||
diff --git a/shared/extra-utils/users/subscriptions-command.ts b/shared/extra-utils/users/subscriptions-command.ts index e998eb426..a69d2a194 100644 --- a/shared/extra-utils/users/subscriptions-command.ts +++ b/shared/extra-utils/users/subscriptions-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { ResultList, Video, VideoChannel } from '@shared/models' | 1 | import { ResultList, Video, VideoChannel } from '@shared/models' |
2 | import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | 3 | import { AbstractCommand, OverrideCommandOptions } from '../shared' |
4 | 4 | ||
5 | export class SubscriptionsCommand extends AbstractCommand { | 5 | export class SubscriptionsCommand extends AbstractCommand { |
diff --git a/shared/extra-utils/users/users-command.ts b/shared/extra-utils/users/users-command.ts index 59dc6d018..f3a251e65 100644 --- a/shared/extra-utils/users/users-command.ts +++ b/shared/extra-utils/users/users-command.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { omit, pick } from 'lodash' | 1 | import { omit, pick } from 'lodash' |
2 | import { HttpStatusCode } from '@shared/core-utils' | 2 | import { HttpStatusCode } from '@shared/models' |
3 | import { | 3 | import { |
4 | MyUser, | 4 | MyUser, |
5 | ResultList, | 5 | ResultList, |
diff --git a/shared/extra-utils/users/users.ts b/shared/extra-utils/users/users.ts deleted file mode 100644 index 6cf61d60e..000000000 --- a/shared/extra-utils/users/users.ts +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | import * as request from 'supertest' | ||
2 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
3 | |||
4 | // FIXME: delete once videos does not use it anymore | ||
5 | function xxxgetMyUserInformation (url: string, accessToken: string, specialStatus = HttpStatusCode.OK_200) { | ||
6 | const path = '/api/v1/users/me' | ||
7 | |||
8 | return request(url) | ||
9 | .get(path) | ||
10 | .set('Accept', 'application/json') | ||
11 | .set('Authorization', 'Bearer ' + accessToken) | ||
12 | .expect(specialStatus) | ||
13 | .expect('Content-Type', /json/) | ||
14 | } | ||
15 | |||
16 | // --------------------------------------------------------------------------- | ||
17 | |||
18 | export { | ||
19 | xxxgetMyUserInformation | ||
20 | } | ||