aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/installer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/installer.ts')
-rw-r--r--server/initializers/installer.ts17
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 @@
1import * as passwordGenerator from 'password-generator' 1import * as passwordGenerator from 'password-generator'
2import { UserRole } from '../../shared' 2import { UserRole } from '../../shared'
3import { createPrivateAndPublicKeys, logger, mkdirpPromise, rimrafPromise } from '../helpers' 3import { logger, mkdirpPromise, rimrafPromise } from '../helpers'
4import { createLocalAccountWithoutKeys, createUserAccountAndChannel } from '../lib' 4import { createApplicationActor, createUserAccountAndChannel } from '../lib/user'
5import { UserModel } from '../models/account/user' 5import { UserModel } from '../models/account/user'
6import { ApplicationModel } from '../models/application/application' 6import { ApplicationModel } from '../models/application/application'
7import { OAuthClientModel } from '../models/oauth/oauth-client' 7import { OAuthClientModel } from '../models/oauth/oauth-client'
8import { applicationExist, clientsExist, usersExist } from './checker' 8import { applicationExist, clientsExist, usersExist } from './checker'
9import { CACHE, CONFIG, LAST_MIGRATION_VERSION, SERVER_ACCOUNT_NAME } from './constants' 9import { CACHE, CONFIG, LAST_MIGRATION_VERSION } from './constants'
10import { sequelizeTypescript } from './database' 10import { sequelizeTypescript } from './database'
11 11
12async function installApplication () { 12async 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}