diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-22 10:29:55 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:53 +0100 |
commit | c986175d68a18e96fbd41537a05c7796a2c64f38 (patch) | |
tree | e8a8a02abb57e637451afbf3b1b0e7a0dbd4206c /server/controllers/activitypub | |
parent | e71bcc0f4b31ecfd84a786411febfc6d18a85258 (diff) | |
download | PeerTube-c986175d68a18e96fbd41537a05c7796a2c64f38.tar.gz PeerTube-c986175d68a18e96fbd41537a05c7796a2c64f38.tar.zst PeerTube-c986175d68a18e96fbd41537a05c7796a2c64f38.zip |
Fetch outbox to grab old activities
Diffstat (limited to 'server/controllers/activitypub')
-rw-r--r-- | server/controllers/activitypub/inbox.ts | 33 | ||||
-rw-r--r-- | server/controllers/activitypub/outbox.ts | 2 |
2 files changed, 2 insertions, 33 deletions
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts index 807d0bdf4..30e7f706b 100644 --- a/server/controllers/activitypub/inbox.ts +++ b/server/controllers/activitypub/inbox.ts | |||
@@ -1,27 +1,10 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, ActivityType, RootActivity } from '../../../shared' | 2 | import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared' |
3 | import { logger } from '../../helpers' | 3 | import { logger } from '../../helpers' |
4 | import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' | 4 | import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' |
5 | import { processCreateActivity, processUpdateActivity, processUndoActivity } from '../../lib' | 5 | import { processActivities } from '../../lib/activitypub/process/process' |
6 | import { processAcceptActivity } from '../../lib/activitypub/process/process-accept' | ||
7 | import { processAddActivity } from '../../lib/activitypub/process/process-add' | ||
8 | import { processAnnounceActivity } from '../../lib/activitypub/process/process-announce' | ||
9 | import { processDeleteActivity } from '../../lib/activitypub/process/process-delete' | ||
10 | import { processFollowActivity } from '../../lib/activitypub/process/process-follow' | ||
11 | import { asyncMiddleware, checkSignature, localAccountValidator, signatureValidator } from '../../middlewares' | 6 | import { asyncMiddleware, checkSignature, localAccountValidator, signatureValidator } from '../../middlewares' |
12 | import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' | 7 | import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' |
13 | import { AccountInstance } from '../../models/account/account-interface' | ||
14 | |||
15 | const processActivity: { [ P in ActivityType ]: (activity: Activity, inboxAccount?: AccountInstance) => Promise<any> } = { | ||
16 | Create: processCreateActivity, | ||
17 | Add: processAddActivity, | ||
18 | Update: processUpdateActivity, | ||
19 | Delete: processDeleteActivity, | ||
20 | Follow: processFollowActivity, | ||
21 | Accept: processAcceptActivity, | ||
22 | Announce: processAnnounceActivity, | ||
23 | Undo: processUndoActivity | ||
24 | } | ||
25 | 8 | ||
26 | const inboxRouter = express.Router() | 9 | const inboxRouter = express.Router() |
27 | 10 | ||
@@ -69,15 +52,3 @@ async function inboxController (req: express.Request, res: express.Response, nex | |||
69 | 52 | ||
70 | res.status(204).end() | 53 | res.status(204).end() |
71 | } | 54 | } |
72 | |||
73 | async function processActivities (activities: Activity[], inboxAccount?: AccountInstance) { | ||
74 | for (const activity of activities) { | ||
75 | const activityProcessor = processActivity[activity.type] | ||
76 | if (activityProcessor === undefined) { | ||
77 | logger.warn('Unknown activity type %s.', activity.type, { activityId: activity.id }) | ||
78 | continue | ||
79 | } | ||
80 | |||
81 | await activityProcessor(activity, inboxAccount) | ||
82 | } | ||
83 | } | ||
diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts index 396fa2db5..1a74bde33 100644 --- a/server/controllers/activitypub/outbox.ts +++ b/server/controllers/activitypub/outbox.ts | |||
@@ -34,8 +34,6 @@ async function outboxController (req: express.Request, res: express.Response, ne | |||
34 | const data = await db.Video.listAllAndSharedByAccountForOutbox(account.id, start, count) | 34 | const data = await db.Video.listAllAndSharedByAccountForOutbox(account.id, start, count) |
35 | const activities: Activity[] = [] | 35 | const activities: Activity[] = [] |
36 | 36 | ||
37 | console.log(account.url) | ||
38 | |||
39 | for (const video of data.data) { | 37 | for (const video of data.data) { |
40 | const videoObject = video.toActivityPubObject() | 38 | const videoObject = video.toActivityPubObject() |
41 | let addActivity: ActivityAdd = await addActivityData(video.url, account, video, video.VideoChannel.url, videoObject) | 39 | let addActivity: ActivityAdd = await addActivityData(video.url, account, video, video.VideoChannel.url, videoObject) |