diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-14 17:38:41 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-19 10:53:16 +0100 |
commit | 50d6de9c286abcb34ff4234d56d9cbb803db7665 (patch) | |
tree | f1732b27edcd05c7877a8358b8312f1e38c287ed /server/controllers/activitypub/outbox.ts | |
parent | fadf619ad61a016c1c7fc53de5a8f398a4f77519 (diff) | |
download | PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.tar.gz PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.tar.zst PeerTube-50d6de9c286abcb34ff4234d56d9cbb803db7665.zip |
Begin moving video channel to actor
Diffstat (limited to 'server/controllers/activitypub/outbox.ts')
-rw-r--r-- | server/controllers/activitypub/outbox.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts index 6ed8a3454..01ba253c6 100644 --- a/server/controllers/activitypub/outbox.ts +++ b/server/controllers/activitypub/outbox.ts | |||
@@ -3,9 +3,8 @@ import { Activity } from '../../../shared/models/activitypub/activity' | |||
3 | import { activityPubCollectionPagination } from '../../helpers/activitypub' | 3 | import { activityPubCollectionPagination } from '../../helpers/activitypub' |
4 | import { pageToStartAndCount } from '../../helpers/core-utils' | 4 | import { pageToStartAndCount } from '../../helpers/core-utils' |
5 | import { ACTIVITY_PUB } from '../../initializers/constants' | 5 | import { ACTIVITY_PUB } from '../../initializers/constants' |
6 | import { addActivityData } from '../../lib/activitypub/send/send-add' | 6 | import { announceActivityData, createActivityData } from '../../lib/activitypub/send' |
7 | import { getAnnounceActivityPubUrl } from '../../lib/activitypub/url' | 7 | import { getAnnounceActivityPubUrl } from '../../lib/activitypub/url' |
8 | import { announceActivityData } from '../../lib/index' | ||
9 | import { asyncMiddleware, localAccountValidator } from '../../middlewares' | 8 | import { asyncMiddleware, localAccountValidator } from '../../middlewares' |
10 | import { AccountModel } from '../../models/account/account' | 9 | import { AccountModel } from '../../models/account/account' |
11 | import { VideoModel } from '../../models/video/video' | 10 | import { VideoModel } from '../../models/video/video' |
@@ -27,29 +26,30 @@ export { | |||
27 | 26 | ||
28 | async function outboxController (req: express.Request, res: express.Response, next: express.NextFunction) { | 27 | async function outboxController (req: express.Request, res: express.Response, next: express.NextFunction) { |
29 | const account: AccountModel = res.locals.account | 28 | const account: AccountModel = res.locals.account |
29 | const actor = account.Actor | ||
30 | 30 | ||
31 | const page = req.query.page || 1 | 31 | const page = req.query.page || 1 |
32 | const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) | 32 | const { start, count } = pageToStartAndCount(page, ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE) |
33 | 33 | ||
34 | const data = await VideoModel.listAllAndSharedByAccountForOutbox(account.id, start, count) | 34 | const data = await VideoModel.listAllAndSharedByActorForOutbox(actor.id, start, count) |
35 | const activities: Activity[] = [] | 35 | const activities: Activity[] = [] |
36 | 36 | ||
37 | for (const video of data.data) { | 37 | for (const video of data.data) { |
38 | const videoObject = video.toActivityPubObject() | 38 | const videoObject = video.toActivityPubObject() |
39 | 39 | ||
40 | // This is a shared video | ||
41 | const videoChannel = video.VideoChannel | 40 | const videoChannel = video.VideoChannel |
41 | // This is a shared video | ||
42 | if (video.VideoShares !== undefined && video.VideoShares.length !== 0) { | 42 | if (video.VideoShares !== undefined && video.VideoShares.length !== 0) { |
43 | const addActivity = await addActivityData(video.url, videoChannel.Account, video, videoChannel.Actor.url, videoObject, undefined) | 43 | const createActivity = await createActivityData(video.url, videoChannel.Account.Actor, videoObject, undefined) |
44 | 44 | ||
45 | const url = getAnnounceActivityPubUrl(video.url, account) | 45 | const url = getAnnounceActivityPubUrl(video.url, actor) |
46 | const announceActivity = await announceActivityData(url, account, addActivity, undefined) | 46 | const announceActivity = await announceActivityData(url, actor, createActivity, undefined) |
47 | 47 | ||
48 | activities.push(announceActivity) | 48 | activities.push(announceActivity) |
49 | } else { | 49 | } else { |
50 | const addActivity = await addActivityData(video.url, account, video, videoChannel.Actor.url, videoObject, undefined) | 50 | const createActivity = await createActivityData(video.url, videoChannel.Account.Actor, videoObject, undefined) |
51 | 51 | ||
52 | activities.push(addActivity) | 52 | activities.push(createActivity) |
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
@@ -57,7 +57,7 @@ async function outboxController (req: express.Request, res: express.Response, ne | |||
57 | data: activities, | 57 | data: activities, |
58 | total: data.total | 58 | total: data.total |
59 | } | 59 | } |
60 | const json = activityPubCollectionPagination(account.url + '/outbox', page, newResult) | 60 | const json = activityPubCollectionPagination(account.Actor.url + '/outbox', page, newResult) |
61 | 61 | ||
62 | return res.json(json).end() | 62 | return res.json(json).end() |
63 | } | 63 | } |