diff options
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/constants.ts | 14 | ||||
-rw-r--r-- | server/initializers/database.ts | 8 | ||||
-rw-r--r-- | server/initializers/installer.ts | 17 | ||||
-rw-r--r-- | server/initializers/migrations/0100-activitypub.ts | 4 |
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 @@ | |||
1 | import * as config from 'config' | 1 | import * as config from 'config' |
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { JobCategory, JobState, VideoRateType } from '../../shared/models' | 3 | import { JobCategory, JobState, VideoRateType } from '../../shared/models' |
4 | import { FollowState } from '../../shared/models/accounts' | 4 | import { FollowState } from '../../shared/models/actors' |
5 | import { ActivityPubActorType } from '../../shared/models/activitypub' | ||
5 | import { VideoPrivacy } from '../../shared/models/videos' | 6 | import { 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 |
7 | import { isTestInstance, root } from '../helpers/core-utils' | 8 | import { isTestInstance, root } from '../helpers/core-utils' |
@@ -210,7 +211,7 @@ const VIDEO_MIMETYPE_EXT = { | |||
210 | 211 | ||
211 | // --------------------------------------------------------------------------- | 212 | // --------------------------------------------------------------------------- |
212 | 213 | ||
213 | const SERVER_ACCOUNT_NAME = 'peertube' | 214 | const SERVER_ACTOR_NAME = 'peertube' |
214 | 215 | ||
215 | const ACTIVITY_PUB = { | 216 | const ACTIVITY_PUB = { |
216 | POTENTIAL_ACCEPT_HEADERS: [ | 217 | POTENTIAL_ACCEPT_HEADERS: [ |
@@ -229,6 +230,12 @@ const ACTIVITY_PUB = { | |||
229 | } | 230 | } |
230 | } | 231 | } |
231 | 232 | ||
233 | const 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' | |||
3 | import { logger } from '../helpers/logger' | 3 | import { logger } from '../helpers/logger' |
4 | 4 | ||
5 | import { AccountModel } from '../models/account/account' | 5 | import { AccountModel } from '../models/account/account' |
6 | import { AccountFollowModel } from '../models/account/account-follow' | ||
7 | import { AccountVideoRateModel } from '../models/account/account-video-rate' | 6 | import { AccountVideoRateModel } from '../models/account/account-video-rate' |
8 | import { UserModel } from '../models/account/user' | 7 | import { UserModel } from '../models/account/user' |
8 | import { ActorModel } from '../models/activitypub/actor' | ||
9 | import { ActorFollowModel } from '../models/activitypub/actor-follow' | ||
9 | import { ApplicationModel } from '../models/application/application' | 10 | import { ApplicationModel } from '../models/application/application' |
10 | import { AvatarModel } from '../models/avatar/avatar' | 11 | import { AvatarModel } from '../models/avatar/avatar' |
11 | import { JobModel } from '../models/job/job' | 12 | import { JobModel } from '../models/job/job' |
@@ -17,7 +18,6 @@ import { VideoModel } from '../models/video/video' | |||
17 | import { VideoAbuseModel } from '../models/video/video-abuse' | 18 | import { VideoAbuseModel } from '../models/video/video-abuse' |
18 | import { VideoBlacklistModel } from '../models/video/video-blacklist' | 19 | import { VideoBlacklistModel } from '../models/video/video-blacklist' |
19 | import { VideoChannelModel } from '../models/video/video-channel' | 20 | import { VideoChannelModel } from '../models/video/video-channel' |
20 | import { VideoChannelShareModel } from '../models/video/video-channel-share' | ||
21 | import { VideoFileModel } from '../models/video/video-file' | 21 | import { VideoFileModel } from '../models/video/video-file' |
22 | import { VideoShareModel } from '../models/video/video-share' | 22 | import { VideoShareModel } from '../models/video/video-share' |
23 | import { VideoTagModel } from '../models/video/video-tag' | 23 | import { VideoTagModel } from '../models/video/video-tag' |
@@ -56,6 +56,8 @@ const sequelizeTypescript = new SequelizeTypescript({ | |||
56 | async function initDatabaseModels (silent: boolean) { | 56 | async 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 @@ | |||
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 | } |
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' | |||
5 | import { getVideoActivityPubUrl, getVideoChannelActivityPubUrl } from '../../lib/activitypub/url' | 5 | import { getVideoActivityPubUrl, getVideoChannelActivityPubUrl } from '../../lib/activitypub/url' |
6 | import { createLocalAccountWithoutKeys } from '../../lib/user' | 6 | import { createLocalAccountWithoutKeys } from '../../lib/user' |
7 | import { ApplicationModel } from '../../models/application/application' | 7 | import { ApplicationModel } from '../../models/application/application' |
8 | import { JOB_CATEGORIES, SERVER_ACCOUNT_NAME } from '../constants' | 8 | import { JOB_CATEGORIES, SERVER_ACTOR_NAME } from '../constants' |
9 | 9 | ||
10 | async function up (utils: { | 10 | async 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) |