Begin moving video channel to actor
This commit is contained in:
parent
fadf619ad6
commit
50d6de9c28
100 changed files with 1761 additions and 2041 deletions
|
@ -3,9 +3,8 @@ import { Activity } from '../../../shared/models/activitypub/activity'
|
|||
import { activityPubCollectionPagination } from '../../helpers/activitypub'
|
||||
import { pageToStartAndCount } from '../../helpers/core-utils'
|
||||
import { ACTIVITY_PUB } from '../../initializers/constants'
|
||||
import { addActivityData } from '../../lib/activitypub/send/send-add'
|
||||
import { announceActivityData, createActivityData } from '../../lib/activitypub/send'
|
||||
import { getAnnounceActivityPubUrl } from '../../lib/activitypub/url'
|
||||
import { announceActivityData } from '../../lib/index'
|
||||
import { asyncMiddleware, localAccountValidator } from '../../middlewares'
|
||||
import { AccountModel } from '../../models/account/account'
|
||||
import { VideoModel } from '../../models/video/video'
|
||||
|
@ -27,29 +26,30 @@ export {
|
|||
|
||||
async function outboxController (req: express.Request, res: express.Response, next: express.NextFunction) {
|
||||
const account: AccountModel = res.locals.account
|
||||
const actor = account.Actor
|
||||
|
||||
const page = req.query.page || 1
|
||||
const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE)
|
||||
|
||||
const data = await VideoModel.listAllAndSharedByAccountForOutbox(account.id, start, count)
|
||||
const data = await VideoModel.listAllAndSharedByActorForOutbox(actor.id, start, count)
|
||||
const activities: Activity[] = []
|
||||
|
||||
for (const video of data.data) {
|
||||
const videoObject = video.toActivityPubObject()
|
||||
|
||||
// This is a shared video
|
||||
const videoChannel = video.VideoChannel
|
||||
// This is a shared video
|
||||
if (video.VideoShares !== undefined && video.VideoShares.length !== 0) {
|
||||
const addActivity = await addActivityData(video.url, videoChannel.Account, video, videoChannel.Actor.url, videoObject, undefined)
|
||||
const createActivity = await createActivityData(video.url, videoChannel.Account.Actor, videoObject, undefined)
|
||||
|
||||
const url = getAnnounceActivityPubUrl(video.url, account)
|
||||
const announceActivity = await announceActivityData(url, account, addActivity, undefined)
|
||||
const url = getAnnounceActivityPubUrl(video.url, actor)
|
||||
const announceActivity = await announceActivityData(url, actor, createActivity, undefined)
|
||||
|
||||
activities.push(announceActivity)
|
||||
} else {
|
||||
const addActivity = await addActivityData(video.url, account, video, videoChannel.Actor.url, videoObject, undefined)
|
||||
const createActivity = await createActivityData(video.url, videoChannel.Account.Actor, videoObject, undefined)
|
||||
|
||||
activities.push(addActivity)
|
||||
activities.push(createActivity)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ async function outboxController (req: express.Request, res: express.Response, ne
|
|||
data: activities,
|
||||
total: data.total
|
||||
}
|
||||
const json = activityPubCollectionPagination(account.url + '/outbox', page, newResult)
|
||||
const json = activityPubCollectionPagination(account.Actor.url + '/outbox', page, newResult)
|
||||
|
||||
return res.json(json).end()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue