]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/migrations/0100-activitypub.ts
Merge branch 'release/v1.3.0' into develop
[github/Chocobozzz/PeerTube.git] / server / initializers / migrations / 0100-activitypub.ts
index fb42e1d57fd3c0d9d93e04bf9f93bb32fded3653..2880a97d9da18656a6273e8671a2796d61ffa2ee 100644 (file)
@@ -1,11 +1,10 @@
-import { values } from 'lodash'
 import * as Sequelize from 'sequelize'
 import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto'
-import { shareVideoByServer } from '../../lib/activitypub/share'
+import { shareVideoByServerAndChannel } from '../../lib/activitypub/share'
 import { getVideoActivityPubUrl, getVideoChannelActivityPubUrl } from '../../lib/activitypub/url'
 import { createLocalAccountWithoutKeys } from '../../lib/user'
 import { ApplicationModel } from '../../models/application/application'
-import { JOB_CATEGORIES, SERVER_ACCOUNT_NAME } from '../constants'
+import { SERVER_ACTOR_NAME } from '../constants'
 
 async function up (utils: {
   transaction: Sequelize.Transaction,
@@ -22,7 +21,7 @@ async function up (utils: {
     const options = {
       type: Sequelize.QueryTypes.SELECT
     }
-    const res = await utils.sequelize.query(query, options)
+    const res = await utils.sequelize.query(query, options) as any
 
     if (!res[0] || res[0].total !== 0) {
       throw new Error('You need to quit friends.')
@@ -66,11 +65,11 @@ async function up (utils: {
   // Create application account
   {
     const applicationInstance = await ApplicationModel.findOne()
-    const accountCreated = await createLocalAccountWithoutKeys(SERVER_ACCOUNT_NAME, null, applicationInstance.id, undefined)
+    const accountCreated = await createLocalAccountWithoutKeys(SERVER_ACTOR_NAME, null, applicationInstance.id, undefined)
 
     const { publicKey, privateKey } = await createPrivateAndPublicKeys()
-    accountCreated.set('publicKey', publicKey)
-    accountCreated.set('privateKey', privateKey)
+    accountCreated.Actor.publicKey = publicKey
+    accountCreated.Actor.privateKey = privateKey
 
     await accountCreated.save()
   }
@@ -87,8 +86,8 @@ async function up (utils: {
     const account = await createLocalAccountWithoutKeys(user.username, user.id, null, undefined)
 
     const { publicKey, privateKey } = await createPrivateAndPublicKeys()
-    account.set('publicKey', publicKey)
-    account.set('privateKey', privateKey)
+    account.Actor.publicKey = publicKey
+    account.Actor.privateKey = privateKey
     await account.save()
   }
 
@@ -161,7 +160,7 @@ async function up (utils: {
 
   {
     const data = {
-      type: Sequelize.ENUM(values(JOB_CATEGORIES)),
+      type: Sequelize.ENUM('transcoding', 'activitypub-http'),
       defaultValue: 'transcoding',
       allowNull: false
     }
@@ -197,7 +196,7 @@ async function up (utils: {
     })
 
     for (const video of videos) {
-      await shareVideoByServer(video, undefined)
+      await shareVideoByServerAndChannel(video, undefined)
     }
   }
 }