diff options
Diffstat (limited to 'server/initializers/installer.ts')
-rw-r--r-- | server/initializers/installer.ts | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/server/initializers/installer.ts b/server/initializers/installer.ts index 5452743b6..ee3c9dfd9 100644 --- a/server/initializers/installer.ts +++ b/server/initializers/installer.ts | |||
@@ -1,12 +1,12 @@ | |||
1 | import * as passwordGenerator from 'password-generator' | 1 | import * as passwordGenerator from 'password-generator' |
2 | import { UserRole } from '../../shared' | 2 | import { UserRole } from '../../shared' |
3 | import { createPrivateAndPublicKeys, logger, mkdirpPromise, rimrafPromise } from '../helpers' | 3 | import { logger, mkdirpPromise, rimrafPromise } from '../helpers' |
4 | import { createLocalAccountWithoutKeys, createUserAccountAndChannel } from '../lib' | 4 | import { createApplicationActor, createUserAccountAndChannel } from '../lib/user' |
5 | import { UserModel } from '../models/account/user' | 5 | import { UserModel } from '../models/account/user' |
6 | import { ApplicationModel } from '../models/application/application' | 6 | import { ApplicationModel } from '../models/application/application' |
7 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 7 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
8 | import { applicationExist, clientsExist, usersExist } from './checker' | 8 | import { applicationExist, clientsExist, usersExist } from './checker' |
9 | import { CACHE, CONFIG, LAST_MIGRATION_VERSION, SERVER_ACCOUNT_NAME } from './constants' | 9 | import { CACHE, CONFIG, LAST_MIGRATION_VERSION } from './constants' |
10 | import { sequelizeTypescript } from './database' | 10 | import { sequelizeTypescript } from './database' |
11 | 11 | ||
12 | async function installApplication () { | 12 | async function installApplication () { |
@@ -134,15 +134,12 @@ async function createApplicationIfNotExist () { | |||
134 | if (exist === true) return undefined | 134 | if (exist === true) return undefined |
135 | 135 | ||
136 | logger.info('Creating Application table.') | 136 | logger.info('Creating Application table.') |
137 | const applicationInstance = await ApplicationModel.create({ migrationVersion: LAST_MIGRATION_VERSION }) | ||
138 | 137 | ||
139 | logger.info('Creating application account.') | 138 | logger.info('Creating application account.') |
140 | 139 | ||
141 | const accountCreated = await createLocalAccountWithoutKeys(SERVER_ACCOUNT_NAME, null, applicationInstance.id, undefined) | 140 | const application = await ApplicationModel.create({ |
142 | 141 | migrationVersion: LAST_MIGRATION_VERSION | |
143 | const { publicKey, privateKey } = await createPrivateAndPublicKeys() | 142 | }) |
144 | accountCreated.set('publicKey', publicKey) | ||
145 | accountCreated.set('privateKey', privateKey) | ||
146 | 143 | ||
147 | return accountCreated.save() | 144 | return createApplicationActor(application.id) |
148 | } | 145 | } |