diff options
author | Chocobozzz <me@florianbigard.com> | 2021-07-16 09:04:35 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-07-20 15:27:18 +0200 |
commit | 89d241a79c262b9775c233b73cff080043ebb5e6 (patch) | |
tree | cb3b6cb431d25d891ef4e02f66c61d252d17048f /shared/extra-utils/users | |
parent | d23dd9fbfc4d26026352c10f81d2795ceaf2908a (diff) | |
download | PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.gz PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.tar.zst PeerTube-89d241a79c262b9775c233b73cff080043ebb5e6.zip |
Shorter server command names
Diffstat (limited to 'shared/extra-utils/users')
-rw-r--r-- | shared/extra-utils/users/accounts.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/users/login-command.ts | 12 | ||||
-rw-r--r-- | shared/extra-utils/users/login.ts | 2 | ||||
-rw-r--r-- | shared/extra-utils/users/notifications.ts | 20 | ||||
-rw-r--r-- | shared/extra-utils/users/users-command.ts | 4 |
5 files changed, 20 insertions, 20 deletions
diff --git a/shared/extra-utils/users/accounts.ts b/shared/extra-utils/users/accounts.ts index ee94351e8..2c9a4b71c 100644 --- a/shared/extra-utils/users/accounts.ts +++ b/shared/extra-utils/users/accounts.ts | |||
@@ -14,7 +14,7 @@ async function expectAccountFollows (options: { | |||
14 | }) { | 14 | }) { |
15 | const { server, handle, followers, following } = options | 15 | const { server, handle, followers, following } = options |
16 | 16 | ||
17 | const body = await server.accountsCommand.list() | 17 | const body = await server.accounts.list() |
18 | const account = body.data.find(a => a.name + '@' + a.host === handle) | 18 | const account = body.data.find(a => a.name + '@' + a.host === handle) |
19 | 19 | ||
20 | const message = `${handle} on ${server.url}` | 20 | const message = `${handle} on ${server.url}` |
diff --git a/shared/extra-utils/users/login-command.ts b/shared/extra-utils/users/login-command.ts index b4e3bb602..10c3db851 100644 --- a/shared/extra-utils/users/login-command.ts +++ b/shared/extra-utils/users/login-command.ts | |||
@@ -9,7 +9,7 @@ export class LoginCommand extends AbstractCommand { | |||
9 | client?: { id?: string, secret?: string } | 9 | client?: { id?: string, secret?: string } |
10 | user?: { username: string, password?: string } | 10 | user?: { username: string, password?: string } |
11 | } = {}) { | 11 | } = {}) { |
12 | const { client = this.server.client, user = this.server.user } = options | 12 | const { client = this.server.store.client, user = this.server.store.user } = options |
13 | const path = '/api/v1/users/token' | 13 | const path = '/api/v1/users/token' |
14 | 14 | ||
15 | const body = { | 15 | const body = { |
@@ -38,7 +38,7 @@ export class LoginCommand extends AbstractCommand { | |||
38 | async getAccessToken (arg1?: { username: string, password?: string } | string, password?: string) { | 38 | async getAccessToken (arg1?: { username: string, password?: string } | string, password?: string) { |
39 | let user: { username: string, password?: string } | 39 | let user: { username: string, password?: string } |
40 | 40 | ||
41 | if (!arg1) user = this.server.user | 41 | if (!arg1) user = this.server.store.user |
42 | else if (typeof arg1 === 'object') user = arg1 | 42 | else if (typeof arg1 === 'object') user = arg1 |
43 | else user = { username: arg1, password } | 43 | else user = { username: arg1, password } |
44 | 44 | ||
@@ -59,8 +59,8 @@ export class LoginCommand extends AbstractCommand { | |||
59 | const path = '/api/v1/users/token' | 59 | const path = '/api/v1/users/token' |
60 | 60 | ||
61 | const body = { | 61 | const body = { |
62 | client_id: this.server.client.id, | 62 | client_id: this.server.store.client.id, |
63 | client_secret: this.server.client.secret, | 63 | client_secret: this.server.store.client.secret, |
64 | username: username, | 64 | username: username, |
65 | response_type: 'code', | 65 | response_type: 'code', |
66 | grant_type: 'password', | 66 | grant_type: 'password', |
@@ -100,8 +100,8 @@ export class LoginCommand extends AbstractCommand { | |||
100 | const path = '/api/v1/users/token' | 100 | const path = '/api/v1/users/token' |
101 | 101 | ||
102 | const body = { | 102 | const body = { |
103 | client_id: this.server.client.id, | 103 | client_id: this.server.store.client.id, |
104 | client_secret: this.server.client.secret, | 104 | client_secret: this.server.store.client.secret, |
105 | refresh_token: options.refreshToken, | 105 | refresh_token: options.refreshToken, |
106 | response_type: 'code', | 106 | response_type: 'code', |
107 | grant_type: 'refresh_token' | 107 | grant_type: 'refresh_token' |
diff --git a/shared/extra-utils/users/login.ts b/shared/extra-utils/users/login.ts index d4ee8e517..d0c26a4f0 100644 --- a/shared/extra-utils/users/login.ts +++ b/shared/extra-utils/users/login.ts | |||
@@ -4,7 +4,7 @@ function setAccessTokensToServers (servers: ServerInfo[]) { | |||
4 | const tasks: Promise<any>[] = [] | 4 | const tasks: Promise<any>[] = [] |
5 | 5 | ||
6 | for (const server of servers) { | 6 | for (const server of servers) { |
7 | const p = server.loginCommand.getAccessToken() | 7 | const p = server.login.getAccessToken() |
8 | .then(t => { server.accessToken = t }) | 8 | .then(t => { server.accessToken = t }) |
9 | tasks.push(p) | 9 | tasks.push(p) |
10 | } | 10 | } |
diff --git a/shared/extra-utils/users/notifications.ts b/shared/extra-utils/users/notifications.ts index 0af7d8a18..9196f0bf5 100644 --- a/shared/extra-utils/users/notifications.ts +++ b/shared/extra-utils/users/notifications.ts | |||
@@ -49,7 +49,7 @@ async function checkNotification ( | |||
49 | const check = base.check || { web: true, mail: true } | 49 | const check = base.check || { web: true, mail: true } |
50 | 50 | ||
51 | if (check.web) { | 51 | if (check.web) { |
52 | const notification = await base.server.notificationsCommand.getLastest({ token: base.token }) | 52 | const notification = await base.server.notifications.getLastest({ token: base.token }) |
53 | 53 | ||
54 | if (notification || checkType !== 'absence') { | 54 | if (notification || checkType !== 'absence') { |
55 | notificationChecker(notification, checkType) | 55 | notificationChecker(notification, checkType) |
@@ -651,31 +651,31 @@ async function prepareNotificationsTest (serversCount = 3, overrideConfigArg: an | |||
651 | } | 651 | } |
652 | 652 | ||
653 | const user = { username: 'user_1', password: 'super password' } | 653 | const user = { username: 'user_1', password: 'super password' } |
654 | await servers[0].usersCommand.create({ ...user, videoQuota: 10 * 1000 * 1000 }) | 654 | await servers[0].users.create({ ...user, videoQuota: 10 * 1000 * 1000 }) |
655 | const userAccessToken = await servers[0].loginCommand.getAccessToken(user) | 655 | const userAccessToken = await servers[0].login.getAccessToken(user) |
656 | 656 | ||
657 | await servers[0].notificationsCommand.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() }) | 657 | await servers[0].notifications.updateMySettings({ token: userAccessToken, settings: getAllNotificationsSettings() }) |
658 | await servers[0].notificationsCommand.updateMySettings({ settings: getAllNotificationsSettings() }) | 658 | await servers[0].notifications.updateMySettings({ settings: getAllNotificationsSettings() }) |
659 | 659 | ||
660 | if (serversCount > 1) { | 660 | if (serversCount > 1) { |
661 | await servers[1].notificationsCommand.updateMySettings({ settings: getAllNotificationsSettings() }) | 661 | await servers[1].notifications.updateMySettings({ settings: getAllNotificationsSettings() }) |
662 | } | 662 | } |
663 | 663 | ||
664 | { | 664 | { |
665 | const socket = servers[0].socketIOCommand.getUserNotificationSocket({ token: userAccessToken }) | 665 | const socket = servers[0].socketIO.getUserNotificationSocket({ token: userAccessToken }) |
666 | socket.on('new-notification', n => userNotifications.push(n)) | 666 | socket.on('new-notification', n => userNotifications.push(n)) |
667 | } | 667 | } |
668 | { | 668 | { |
669 | const socket = servers[0].socketIOCommand.getUserNotificationSocket() | 669 | const socket = servers[0].socketIO.getUserNotificationSocket() |
670 | socket.on('new-notification', n => adminNotifications.push(n)) | 670 | socket.on('new-notification', n => adminNotifications.push(n)) |
671 | } | 671 | } |
672 | 672 | ||
673 | if (serversCount > 1) { | 673 | if (serversCount > 1) { |
674 | const socket = servers[1].socketIOCommand.getUserNotificationSocket() | 674 | const socket = servers[1].socketIO.getUserNotificationSocket() |
675 | socket.on('new-notification', n => adminNotificationsServer2.push(n)) | 675 | socket.on('new-notification', n => adminNotificationsServer2.push(n)) |
676 | } | 676 | } |
677 | 677 | ||
678 | const { videoChannels } = await servers[0].usersCommand.getMyInfo() | 678 | const { videoChannels } = await servers[0].users.getMyInfo() |
679 | const channelId = videoChannels[0].id | 679 | const channelId = videoChannels[0].id |
680 | 680 | ||
681 | return { | 681 | return { |
diff --git a/shared/extra-utils/users/users-command.ts b/shared/extra-utils/users/users-command.ts index 202528b8d..59dc6d018 100644 --- a/shared/extra-utils/users/users-command.ts +++ b/shared/extra-utils/users/users-command.ts | |||
@@ -194,7 +194,7 @@ export class UsersCommand extends AbstractCommand { | |||
194 | const password = 'password' | 194 | const password = 'password' |
195 | const user = await this.create({ username, password }) | 195 | const user = await this.create({ username, password }) |
196 | 196 | ||
197 | const token = await this.server.loginCommand.getAccessToken({ username, password }) | 197 | const token = await this.server.login.getAccessToken({ username, password }) |
198 | 198 | ||
199 | const me = await this.getMyInfo({ token }) | 199 | const me = await this.getMyInfo({ token }) |
200 | 200 | ||
@@ -209,7 +209,7 @@ export class UsersCommand extends AbstractCommand { | |||
209 | const password = 'password' | 209 | const password = 'password' |
210 | await this.create({ username, password }) | 210 | await this.create({ username, password }) |
211 | 211 | ||
212 | return this.server.loginCommand.getAccessToken({ username, password }) | 212 | return this.server.login.getAccessToken({ username, password }) |
213 | } | 213 | } |
214 | 214 | ||
215 | register (options: OverrideCommandOptions & { | 215 | register (options: OverrideCommandOptions & { |