diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/fetch.ts | 15 | ||||
-rw-r--r-- | server/lib/activitypub/index.ts | 1 | ||||
-rw-r--r-- | server/lib/activitypub/process/index.ts | 1 | ||||
-rw-r--r-- | server/lib/activitypub/process/process.ts | 38 | ||||
-rw-r--r-- | server/lib/activitypub/send/send-create.ts | 2 |
5 files changed, 57 insertions, 0 deletions
diff --git a/server/lib/activitypub/fetch.ts b/server/lib/activitypub/fetch.ts new file mode 100644 index 000000000..fd2af0761 --- /dev/null +++ b/server/lib/activitypub/fetch.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | import { Transaction } from 'sequelize' | ||
2 | import { AccountInstance } from '../../models/account/account-interface' | ||
3 | import { activitypubHttpJobScheduler, ActivityPubHttpPayload } from '../jobs/activitypub-http-job-scheduler/activitypub-http-job-scheduler' | ||
4 | |||
5 | async function addFetchOutboxJob (account: AccountInstance, t: Transaction) { | ||
6 | const jobPayload: ActivityPubHttpPayload = { | ||
7 | uris: [ account.outboxUrl ] | ||
8 | } | ||
9 | |||
10 | return activitypubHttpJobScheduler.createJob(t, 'activitypubHttpFetcherHandler', jobPayload) | ||
11 | } | ||
12 | |||
13 | export { | ||
14 | addFetchOutboxJob | ||
15 | } | ||
diff --git a/server/lib/activitypub/index.ts b/server/lib/activitypub/index.ts index b1daa70bb..fcea662a6 100644 --- a/server/lib/activitypub/index.ts +++ b/server/lib/activitypub/index.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | export * from './process' | 1 | export * from './process' |
2 | export * from './send' | 2 | export * from './send' |
3 | export * from './account' | 3 | export * from './account' |
4 | export * from './fetch' | ||
4 | export * from './share' | 5 | export * from './share' |
5 | export * from './video-channels' | 6 | export * from './video-channels' |
6 | export * from './videos' | 7 | export * from './videos' |
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 @@ | |||
1 | export * from './process' | ||
1 | export * from './process-accept' | 2 | export * from './process-accept' |
2 | export * from './process-add' | 3 | export * from './process-add' |
3 | export * from './process-announce' | 4 | export * 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 @@ | |||
1 | import { Activity, ActivityType } from '../../../../shared/models/activitypub/activity' | ||
2 | import { AccountInstance } from '../../../models/account/account-interface' | ||
3 | import { processAcceptActivity } from './process-accept' | ||
4 | import { processAddActivity } from './process-add' | ||
5 | import { processAnnounceActivity } from './process-announce' | ||
6 | import { processCreateActivity } from './process-create' | ||
7 | import { processDeleteActivity } from './process-delete' | ||
8 | import { processFollowActivity } from './process-follow' | ||
9 | import { processUndoActivity } from './process-undo' | ||
10 | import { processUpdateActivity } from './process-update' | ||
11 | import { logger } from '../../../helpers/logger' | ||
12 | |||
13 | const 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 | |||
24 | async 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 | |||
36 | export { | ||
37 | processActivities | ||
38 | } | ||
diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts index 14b666fc9..df8e0a642 100644 --- a/server/lib/activitypub/send/send-create.ts +++ b/server/lib/activitypub/send/send-create.ts | |||
@@ -21,6 +21,8 @@ async function sendVideoAbuse (byAccount: AccountInstance, videoAbuse: VideoAbus | |||
21 | return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) | 21 | return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) |
22 | } | 22 | } |
23 | 23 | ||
24 | // async function sendCreateView () | ||
25 | |||
24 | async function createActivityData (url: string, byAccount: AccountInstance, object: any) { | 26 | async function createActivityData (url: string, byAccount: AccountInstance, object: any) { |
25 | const { to, cc } = await getAudience(byAccount) | 27 | const { to, cc } = await getAudience(byAccount) |
26 | const activity: ActivityCreate = { | 28 | const activity: ActivityCreate = { |