aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts14
-rw-r--r--server/initializers/database.ts8
-rw-r--r--server/initializers/installer.ts17
-rw-r--r--server/initializers/migrations/0100-activitypub.ts4
4 files changed, 24 insertions, 19 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index f209bef90..04b610b7a 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -1,7 +1,8 @@
1import * as config from 'config' 1import * as config from 'config'
2import { join } from 'path' 2import { join } from 'path'
3import { JobCategory, JobState, VideoRateType } from '../../shared/models' 3import { JobCategory, JobState, VideoRateType } from '../../shared/models'
4import { FollowState } from '../../shared/models/accounts' 4import { FollowState } from '../../shared/models/actors'
5import { ActivityPubActorType } from '../../shared/models/activitypub'
5import { VideoPrivacy } from '../../shared/models/videos' 6import { VideoPrivacy } from '../../shared/models/videos'
6// Do not use barrels, remain constants as independent as possible 7// Do not use barrels, remain constants as independent as possible
7import { isTestInstance, root } from '../helpers/core-utils' 8import { isTestInstance, root } from '../helpers/core-utils'
@@ -210,7 +211,7 @@ const VIDEO_MIMETYPE_EXT = {
210 211
211// --------------------------------------------------------------------------- 212// ---------------------------------------------------------------------------
212 213
213const SERVER_ACCOUNT_NAME = 'peertube' 214const SERVER_ACTOR_NAME = 'peertube'
214 215
215const ACTIVITY_PUB = { 216const ACTIVITY_PUB = {
216 POTENTIAL_ACCEPT_HEADERS: [ 217 POTENTIAL_ACCEPT_HEADERS: [
@@ -229,6 +230,12 @@ const ACTIVITY_PUB = {
229 } 230 }
230} 231}
231 232
233const ACTIVITY_PUB_ACTOR_TYPES: { [ id: string ]: ActivityPubActorType } = {
234 GROUP: 'Group',
235 PERSON: 'Person',
236 APPLICATION: 'Application'
237}
238
232// --------------------------------------------------------------------------- 239// ---------------------------------------------------------------------------
233 240
234// Number of points we add/remove from a friend after a successful/bad request 241// Number of points we add/remove from a friend after a successful/bad request
@@ -350,12 +357,13 @@ export {
350 REMOTE_SCHEME, 357 REMOTE_SCHEME,
351 FOLLOW_STATES, 358 FOLLOW_STATES,
352 AVATARS_DIR, 359 AVATARS_DIR,
353 SERVER_ACCOUNT_NAME, 360 SERVER_ACTOR_NAME,
354 PRIVATE_RSA_KEY_SIZE, 361 PRIVATE_RSA_KEY_SIZE,
355 SORTABLE_COLUMNS, 362 SORTABLE_COLUMNS,
356 STATIC_MAX_AGE, 363 STATIC_MAX_AGE,
357 STATIC_PATHS, 364 STATIC_PATHS,
358 ACTIVITY_PUB, 365 ACTIVITY_PUB,
366 ACTIVITY_PUB_ACTOR_TYPES,
359 THUMBNAILS_SIZE, 367 THUMBNAILS_SIZE,
360 VIDEO_CATEGORIES, 368 VIDEO_CATEGORIES,
361 VIDEO_LANGUAGES, 369 VIDEO_LANGUAGES,
diff --git a/server/initializers/database.ts b/server/initializers/database.ts
index 85d205cdc..0b3f695f7 100644
--- a/server/initializers/database.ts
+++ b/server/initializers/database.ts
@@ -3,9 +3,10 @@ import { isTestInstance } from '../helpers/core-utils'
3import { logger } from '../helpers/logger' 3import { logger } from '../helpers/logger'
4 4
5import { AccountModel } from '../models/account/account' 5import { AccountModel } from '../models/account/account'
6import { AccountFollowModel } from '../models/account/account-follow'
7import { AccountVideoRateModel } from '../models/account/account-video-rate' 6import { AccountVideoRateModel } from '../models/account/account-video-rate'
8import { UserModel } from '../models/account/user' 7import { UserModel } from '../models/account/user'
8import { ActorModel } from '../models/activitypub/actor'
9import { ActorFollowModel } from '../models/activitypub/actor-follow'
9import { ApplicationModel } from '../models/application/application' 10import { ApplicationModel } from '../models/application/application'
10import { AvatarModel } from '../models/avatar/avatar' 11import { AvatarModel } from '../models/avatar/avatar'
11import { JobModel } from '../models/job/job' 12import { JobModel } from '../models/job/job'
@@ -17,7 +18,6 @@ import { VideoModel } from '../models/video/video'
17import { VideoAbuseModel } from '../models/video/video-abuse' 18import { VideoAbuseModel } from '../models/video/video-abuse'
18import { VideoBlacklistModel } from '../models/video/video-blacklist' 19import { VideoBlacklistModel } from '../models/video/video-blacklist'
19import { VideoChannelModel } from '../models/video/video-channel' 20import { VideoChannelModel } from '../models/video/video-channel'
20import { VideoChannelShareModel } from '../models/video/video-channel-share'
21import { VideoFileModel } from '../models/video/video-file' 21import { VideoFileModel } from '../models/video/video-file'
22import { VideoShareModel } from '../models/video/video-share' 22import { VideoShareModel } from '../models/video/video-share'
23import { VideoTagModel } from '../models/video/video-tag' 23import { VideoTagModel } from '../models/video/video-tag'
@@ -56,6 +56,8 @@ const sequelizeTypescript = new SequelizeTypescript({
56async function initDatabaseModels (silent: boolean) { 56async function initDatabaseModels (silent: boolean) {
57 sequelizeTypescript.addModels([ 57 sequelizeTypescript.addModels([
58 ApplicationModel, 58 ApplicationModel,
59 ActorModel,
60 ActorFollowModel,
59 AvatarModel, 61 AvatarModel,
60 AccountModel, 62 AccountModel,
61 JobModel, 63 JobModel,
@@ -64,11 +66,9 @@ async function initDatabaseModels (silent: boolean) {
64 ServerModel, 66 ServerModel,
65 TagModel, 67 TagModel,
66 AccountVideoRateModel, 68 AccountVideoRateModel,
67 AccountFollowModel,
68 UserModel, 69 UserModel,
69 VideoAbuseModel, 70 VideoAbuseModel,
70 VideoChannelModel, 71 VideoChannelModel,
71 VideoChannelShareModel,
72 VideoShareModel, 72 VideoShareModel,
73 VideoFileModel, 73 VideoFileModel,
74 VideoBlacklistModel, 74 VideoBlacklistModel,
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}
diff --git a/server/initializers/migrations/0100-activitypub.ts b/server/initializers/migrations/0100-activitypub.ts
index fb42e1d57..d896b3205 100644
--- a/server/initializers/migrations/0100-activitypub.ts
+++ b/server/initializers/migrations/0100-activitypub.ts
@@ -5,7 +5,7 @@ import { shareVideoByServer } from '../../lib/activitypub/share'
5import { getVideoActivityPubUrl, getVideoChannelActivityPubUrl } from '../../lib/activitypub/url' 5import { getVideoActivityPubUrl, getVideoChannelActivityPubUrl } from '../../lib/activitypub/url'
6import { createLocalAccountWithoutKeys } from '../../lib/user' 6import { createLocalAccountWithoutKeys } from '../../lib/user'
7import { ApplicationModel } from '../../models/application/application' 7import { ApplicationModel } from '../../models/application/application'
8import { JOB_CATEGORIES, SERVER_ACCOUNT_NAME } from '../constants' 8import { JOB_CATEGORIES, SERVER_ACTOR_NAME } from '../constants'
9 9
10async function up (utils: { 10async function up (utils: {
11 transaction: Sequelize.Transaction, 11 transaction: Sequelize.Transaction,
@@ -66,7 +66,7 @@ async function up (utils: {
66 // Create application account 66 // Create application account
67 { 67 {
68 const applicationInstance = await ApplicationModel.findOne() 68 const applicationInstance = await ApplicationModel.findOne()
69 const accountCreated = await createLocalAccountWithoutKeys(SERVER_ACCOUNT_NAME, null, applicationInstance.id, undefined) 69 const accountCreated = await createLocalAccountWithoutKeys(SERVER_ACTOR_NAME, null, applicationInstance.id, undefined)
70 70
71 const { publicKey, privateKey } = await createPrivateAndPublicKeys() 71 const { publicKey, privateKey } = await createPrivateAndPublicKeys()
72 accountCreated.set('publicKey', publicKey) 72 accountCreated.set('publicKey', publicKey)