blob: 6135973411c7f373700f9b0d046fdea7805ba0b4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
import { Activity, ActivityType } from '../../../../shared/models/activitypub/activity'
import { AccountInstance } from '../../../models/account/account-interface'
import { processAcceptActivity } from './process-accept'
import { processAddActivity } from './process-add'
import { processAnnounceActivity } from './process-announce'
import { processCreateActivity } from './process-create'
import { processDeleteActivity } from './process-delete'
import { processFollowActivity } from './process-follow'
import { processUndoActivity } from './process-undo'
import { processUpdateActivity } from './process-update'
import { logger } from '../../../helpers/logger'
const processActivity: { [ P in ActivityType ]: (activity: Activity, inboxAccount?: AccountInstance) => Promise<any> } = {
Create: processCreateActivity,
Add: processAddActivity,
Update: processUpdateActivity,
Delete: processDeleteActivity,
Follow: processFollowActivity,
Accept: processAcceptActivity,
Announce: processAnnounceActivity,
Undo: processUndoActivity
}
async function processActivities (activities: Activity[], inboxAccount?: AccountInstance) {
for (const activity of activities) {
const activityProcessor = processActivity[activity.type]
if (activityProcessor === undefined) {
logger.warn('Unknown activity type %s.', activity.type, { activityId: activity.id })
continue
}
await activityProcessor(activity, inboxAccount)
}
}
export {
processActivities
}
|