1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 18:29:27 +02:00

Begin moving video channel to actor

This commit is contained in:
Chocobozzz 2017-12-14 17:38:41 +01:00
parent fadf619ad6
commit 50d6de9c28
No known key found for this signature in database
GPG key ID: 583A612D890159BE
100 changed files with 1761 additions and 2041 deletions

View file

@ -1,14 +1,14 @@
import { ActivityAccept } from '../../../../shared/models/activitypub'
import { AccountModel } from '../../../models/account/account'
import { AccountFollowModel } from '../../../models/account/account-follow'
import { ActorModel } from '../../../models/activitypub/actor'
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { addFetchOutboxJob } from '../fetch'
async function processAcceptActivity (activity: ActivityAccept, inboxAccount?: AccountModel) {
if (inboxAccount === undefined) throw new Error('Need to accept on explicit inbox.')
async function processAcceptActivity (activity: ActivityAccept, inboxActor?: ActorModel) {
if (inboxActor === undefined) throw new Error('Need to accept on explicit inbox.')
const targetAccount = await AccountModel.loadByUrl(activity.actor)
const targetActor = await ActorModel.loadByUrl(activity.actor)
return processAccept(inboxAccount, targetAccount)
return processAccept(inboxActor, targetActor)
}
// ---------------------------------------------------------------------------
@ -19,11 +19,11 @@ export {
// ---------------------------------------------------------------------------
async function processAccept (account: AccountModel, targetAccount: AccountModel) {
const follow = await AccountFollowModel.loadByAccountAndTarget(account.id, targetAccount.id)
async function processAccept (actor: ActorModel, targetActor: ActorModel) {
const follow = await ActorFollowModel.loadByActorAndTarget(actor.id, targetActor.id)
if (!follow) throw new Error('Cannot find associated follow.')
follow.set('state', 'accepted')
await follow.save()
await addFetchOutboxJob(targetAccount, undefined)
await addFetchOutboxJob(targetActor, undefined)
}