aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-22 10:29:55 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:53 +0100
commitc986175d68a18e96fbd41537a05c7796a2c64f38 (patch)
treee8a8a02abb57e637451afbf3b1b0e7a0dbd4206c /server/lib/activitypub/process
parente71bcc0f4b31ecfd84a786411febfc6d18a85258 (diff)
downloadPeerTube-c986175d68a18e96fbd41537a05c7796a2c64f38.tar.gz
PeerTube-c986175d68a18e96fbd41537a05c7796a2c64f38.tar.zst
PeerTube-c986175d68a18e96fbd41537a05c7796a2c64f38.zip
Fetch outbox to grab old activities
Diffstat (limited to 'server/lib/activitypub/process')
-rw-r--r--server/lib/activitypub/process/index.ts1
-rw-r--r--server/lib/activitypub/process/process.ts38
2 files changed, 39 insertions, 0 deletions
diff --git a/server/lib/activitypub/process/index.ts b/server/lib/activitypub/process/index.ts
index e80b46b6f..c68312053 100644
--- a/server/lib/activitypub/process/index.ts
+++ b/server/lib/activitypub/process/index.ts
@@ -1,3 +1,4 @@
1export * from './process'
1export * from './process-accept' 2export * from './process-accept'
2export * from './process-add' 3export * from './process-add'
3export * from './process-announce' 4export * from './process-announce'
diff --git a/server/lib/activitypub/process/process.ts b/server/lib/activitypub/process/process.ts
new file mode 100644
index 000000000..613597341
--- /dev/null
+++ b/server/lib/activitypub/process/process.ts
@@ -0,0 +1,38 @@
1import { Activity, ActivityType } from '../../../../shared/models/activitypub/activity'
2import { AccountInstance } from '../../../models/account/account-interface'
3import { processAcceptActivity } from './process-accept'
4import { processAddActivity } from './process-add'
5import { processAnnounceActivity } from './process-announce'
6import { processCreateActivity } from './process-create'
7import { processDeleteActivity } from './process-delete'
8import { processFollowActivity } from './process-follow'
9import { processUndoActivity } from './process-undo'
10import { processUpdateActivity } from './process-update'
11import { logger } from '../../../helpers/logger'
12
13const processActivity: { [ P in ActivityType ]: (activity: Activity, inboxAccount?: AccountInstance) => Promise<any> } = {
14 Create: processCreateActivity,
15 Add: processAddActivity,
16 Update: processUpdateActivity,
17 Delete: processDeleteActivity,
18 Follow: processFollowActivity,
19 Accept: processAcceptActivity,
20 Announce: processAnnounceActivity,
21 Undo: processUndoActivity
22}
23
24async function processActivities (activities: Activity[], inboxAccount?: AccountInstance) {
25 for (const activity of activities) {
26 const activityProcessor = processActivity[activity.type]
27 if (activityProcessor === undefined) {
28 logger.warn('Unknown activity type %s.', activity.type, { activityId: activity.id })
29 continue
30 }
31
32 await activityProcessor(activity, inboxAccount)
33 }
34}
35
36export {
37 processActivities
38}