mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Save
This commit is contained in:
parent
7efe153b0b
commit
fadf619ad6
15 changed files with 426 additions and 351 deletions
|
@ -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
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue