aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/activitypub/inbox.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/activitypub/inbox.ts')
-rw-r--r--server/controllers/activitypub/inbox.ts33
1 files changed, 2 insertions, 31 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 @@
1import * as express from 'express' 1import * as express from 'express'
2import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, ActivityType, RootActivity } from '../../../shared' 2import { Activity, ActivityPubCollection, ActivityPubOrderedCollection, RootActivity } from '../../../shared'
3import { logger } from '../../helpers' 3import { logger } from '../../helpers'
4import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity' 4import { isActivityValid } from '../../helpers/custom-validators/activitypub/activity'
5import { processCreateActivity, processUpdateActivity, processUndoActivity } from '../../lib' 5import { processActivities } from '../../lib/activitypub/process/process'
6import { processAcceptActivity } from '../../lib/activitypub/process/process-accept'
7import { processAddActivity } from '../../lib/activitypub/process/process-add'
8import { processAnnounceActivity } from '../../lib/activitypub/process/process-announce'
9import { processDeleteActivity } from '../../lib/activitypub/process/process-delete'
10import { processFollowActivity } from '../../lib/activitypub/process/process-follow'
11import { asyncMiddleware, checkSignature, localAccountValidator, signatureValidator } from '../../middlewares' 6import { asyncMiddleware, checkSignature, localAccountValidator, signatureValidator } from '../../middlewares'
12import { activityPubValidator } from '../../middlewares/validators/activitypub/activity' 7import { activityPubValidator } from '../../middlewares/validators/activitypub/activity'
13import { AccountInstance } from '../../models/account/account-interface'
14
15const 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
26const inboxRouter = express.Router() 9const 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
73async 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}