diff options
author | Chocobozzz <me@florianbigard.com> | 2018-11-19 15:21:09 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-11-19 15:21:09 +0100 |
commit | 0b2f03d3712f438f67eccf86b67acd047284f9b4 (patch) | |
tree | b6ae2ca2405d6a915e6be34e1d3c4e04312f6f03 /server/lib/user.ts | |
parent | 361805c48b14c5402c9984485c67c45a1a3113cc (diff) | |
download | PeerTube-0b2f03d3712f438f67eccf86b67acd047284f9b4.tar.gz PeerTube-0b2f03d3712f438f67eccf86b67acd047284f9b4.tar.zst PeerTube-0b2f03d3712f438f67eccf86b67acd047284f9b4.zip |
Speedup peertube startup
Diffstat (limited to 'server/lib/user.ts')
-rw-r--r-- | server/lib/user.ts | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/server/lib/user.ts b/server/lib/user.ts index db29469eb..acb883e23 100644 --- a/server/lib/user.ts +++ b/server/lib/user.ts | |||
@@ -17,8 +17,10 @@ async function createUserAccountAndChannel (userToCreate: UserModel, validateUse | |||
17 | validate: validateUser | 17 | validate: validateUser |
18 | } | 18 | } |
19 | 19 | ||
20 | const userCreated = await userToCreate.save(userOptions) | 20 | const [ userCreated, accountCreated ] = await Promise.all([ |
21 | const accountCreated = await createLocalAccountWithoutKeys(userToCreate.username, userToCreate.id, null, t) | 21 | userToCreate.save(userOptions), |
22 | createLocalAccountWithoutKeys(userToCreate.username, userToCreate.id, null, t) | ||
23 | ]) | ||
22 | userCreated.Account = accountCreated | 24 | userCreated.Account = accountCreated |
23 | 25 | ||
24 | let channelName = userCreated.username + '_channel' | 26 | let channelName = userCreated.username + '_channel' |
@@ -37,8 +39,13 @@ async function createUserAccountAndChannel (userToCreate: UserModel, validateUse | |||
37 | return { user: userCreated, account: accountCreated, videoChannel } | 39 | return { user: userCreated, account: accountCreated, videoChannel } |
38 | }) | 40 | }) |
39 | 41 | ||
40 | account.Actor = await setAsyncActorKeys(account.Actor) | 42 | const [ accountKeys, channelKeys ] = await Promise.all([ |
41 | videoChannel.Actor = await setAsyncActorKeys(videoChannel.Actor) | 43 | setAsyncActorKeys(account.Actor), |
44 | setAsyncActorKeys(videoChannel.Actor) | ||
45 | ]) | ||
46 | |||
47 | account.Actor = accountKeys | ||
48 | videoChannel.Actor = channelKeys | ||
42 | 49 | ||
43 | return { user, account, videoChannel } as { user: UserModel, account: AccountModel, videoChannel: VideoChannelModel } | 50 | return { user, account, videoChannel } as { user: UserModel, account: AccountModel, videoChannel: VideoChannelModel } |
44 | } | 51 | } |