1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00
This commit is contained in:
Chocobozzz 2017-12-14 11:18:49 +01:00
parent 7efe153b0b
commit fadf619ad6
No known key found for this signature in database
GPG key ID: 583A612D890159BE
15 changed files with 426 additions and 351 deletions

View file

@ -3,6 +3,7 @@ import { createPrivateAndPublicKeys, logger } from '../helpers'
import { CONFIG, sequelizeTypescript } from '../initializers'
import { AccountModel } from '../models/account/account'
import { UserModel } from '../models/account/user'
import { ActorModel } from '../models/activitypub/actor'
import { getAccountActivityPubUrl } from './activitypub'
import { createVideoChannel } from './video-channel'
@ -27,9 +28,10 @@ async function createUserAccountAndChannel (user: UserModel, validateUser = true
// Set account keys, this could be long so process after the account creation and do not block the client
const { publicKey, privateKey } = await createPrivateAndPublicKeys()
account.set('publicKey', publicKey)
account.set('privateKey', privateKey)
account.save().catch(err => logger.error('Cannot set public/private keys of local account %d.', account.id, err))
const actor = account.Actor
actor.set('publicKey', publicKey)
actor.set('privateKey', privateKey)
actor.save().catch(err => logger.error('Cannot set public/private keys of actor %d.', actor.uuid, err))
return { account, videoChannel }
}
@ -37,8 +39,7 @@ async function createUserAccountAndChannel (user: UserModel, validateUser = true
async function createLocalAccountWithoutKeys (name: string, userId: number, applicationId: number, t: Sequelize.Transaction) {
const url = getAccountActivityPubUrl(name)
const accountInstance = new AccountModel({
name,
const actorInstance = new ActorModel({
url,
publicKey: null,
privateKey: null,
@ -48,13 +49,22 @@ async function createLocalAccountWithoutKeys (name: string, userId: number, appl
outboxUrl: url + '/outbox',
sharedInboxUrl: CONFIG.WEBSERVER.URL + '/inbox',
followersUrl: url + '/followers',
followingUrl: url + '/following',
followingUrl: url + '/following'
})
const actorInstanceCreated = await actorInstance.save({ transaction: t })
const accountInstance = new AccountModel({
name,
userId,
applicationId,
actorId: actorInstanceCreated.id,
serverId: null // It is our server
})
return accountInstance.save({ transaction: t })
const accountInstanceCreated = await accountInstance.save({ transaction: t })
accountInstanceCreated.Actor = actorInstanceCreated
return accountInstanceCreated
}
// ---------------------------------------------------------------------------