aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/activitypub
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/activitypub')
-rw-r--r--server/controllers/activitypub/inbox.ts33
-rw-r--r--server/controllers/activitypub/outbox.ts2
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 @@
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}
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)