1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Begin activitypub

This commit is contained in:
Chocobozzz 2017-11-09 17:51:58 +01:00
parent 343ad675f2
commit e4f97babf7
No known key found for this signature in database
GPG key ID: 583A612D890159BE
92 changed files with 2507 additions and 920 deletions

View file

@ -1,9 +1,9 @@
import { database as db } from '../initializers'
import { UserInstance } from '../models'
import { addVideoAuthorToFriends } from './friends'
import { addVideoAccountToFriends } from './friends'
import { createVideoChannel } from './video-channel'
async function createUserAuthorAndChannel (user: UserInstance, validateUser = true) {
async function createUserAccountAndChannel (user: UserInstance, validateUser = true) {
const res = await db.sequelize.transaction(async t => {
const userOptions = {
transaction: t,
@ -11,25 +11,25 @@ async function createUserAuthorAndChannel (user: UserInstance, validateUser = tr
}
const userCreated = await user.save(userOptions)
const authorInstance = db.Author.build({
const accountInstance = db.Account.build({
name: userCreated.username,
podId: null, // It is our pod
userId: userCreated.id
})
const authorCreated = await authorInstance.save({ transaction: t })
const accountCreated = await accountInstance.save({ transaction: t })
const remoteVideoAuthor = authorCreated.toAddRemoteJSON()
const remoteVideoAccount = accountCreated.toAddRemoteJSON()
// Now we'll add the video channel's meta data to our friends
const author = await addVideoAuthorToFriends(remoteVideoAuthor, t)
const account = await addVideoAccountToFriends(remoteVideoAccount, t)
const videoChannelInfo = {
name: `Default ${userCreated.username} channel`
}
const videoChannel = await createVideoChannel(videoChannelInfo, authorCreated, t)
const videoChannel = await createVideoChannel(videoChannelInfo, accountCreated, t)
return { author, videoChannel }
return { account, videoChannel }
})
return res
@ -38,5 +38,5 @@ async function createUserAuthorAndChannel (user: UserInstance, validateUser = tr
// ---------------------------------------------------------------------------
export {
createUserAuthorAndChannel
createUserAccountAndChannel
}