diff options
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/process/process-accept.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-announce.ts | 13 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-create.ts | 19 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-delete.ts | 5 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-dislike.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-flag.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-follow.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-like.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-reject.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-undo.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-update.ts | 5 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-view.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/process/process.ts | 23 |
13 files changed, 67 insertions, 30 deletions
diff --git a/server/lib/activitypub/process/process-accept.ts b/server/lib/activitypub/process/process-accept.ts index ebb275e34..72bb1975e 100644 --- a/server/lib/activitypub/process/process-accept.ts +++ b/server/lib/activitypub/process/process-accept.ts | |||
@@ -2,8 +2,10 @@ import { ActivityAccept } from '../../../../shared/models/activitypub' | |||
2 | import { ActorModel } from '../../../models/activitypub/actor' | 2 | import { ActorModel } from '../../../models/activitypub/actor' |
3 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 3 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
4 | import { addFetchOutboxJob } from '../actor' | 4 | import { addFetchOutboxJob } from '../actor' |
5 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
5 | 6 | ||
6 | async function processAcceptActivity (activity: ActivityAccept, targetActor: ActorModel, inboxActor?: ActorModel) { | 7 | async function processAcceptActivity (options: APProcessorOptions<ActivityAccept>) { |
8 | const { byActor: targetActor, inboxActor } = options | ||
7 | if (inboxActor === undefined) throw new Error('Need to accept on explicit inbox.') | 9 | if (inboxActor === undefined) throw new Error('Need to accept on explicit inbox.') |
8 | 10 | ||
9 | return processAccept(inboxActor, targetActor) | 11 | return processAccept(inboxActor, targetActor) |
diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts index 1fe347506..7a59bb84d 100644 --- a/server/lib/activitypub/process/process-announce.ts +++ b/server/lib/activitypub/process/process-announce.ts | |||
@@ -8,9 +8,14 @@ import { getOrCreateVideoAndAccountAndChannel } from '../videos' | |||
8 | import { Notifier } from '../../notifier' | 8 | import { Notifier } from '../../notifier' |
9 | import { VideoModel } from '../../../models/video/video' | 9 | import { VideoModel } from '../../../models/video/video' |
10 | import { logger } from '../../../helpers/logger' | 10 | import { logger } from '../../../helpers/logger' |
11 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
11 | 12 | ||
12 | async function processAnnounceActivity (activity: ActivityAnnounce, actorAnnouncer: ActorModel) { | 13 | async function processAnnounceActivity (options: APProcessorOptions<ActivityAnnounce>) { |
13 | return retryTransactionWrapper(processVideoShare, actorAnnouncer, activity) | 14 | const { activity, byActor: actorAnnouncer } = options |
15 | // Only notify if it is not from a fetcher job | ||
16 | const notify = options.fromFetch !== true | ||
17 | |||
18 | return retryTransactionWrapper(processVideoShare, actorAnnouncer, activity, notify) | ||
14 | } | 19 | } |
15 | 20 | ||
16 | // --------------------------------------------------------------------------- | 21 | // --------------------------------------------------------------------------- |
@@ -21,7 +26,7 @@ export { | |||
21 | 26 | ||
22 | // --------------------------------------------------------------------------- | 27 | // --------------------------------------------------------------------------- |
23 | 28 | ||
24 | async function processVideoShare (actorAnnouncer: ActorModel, activity: ActivityAnnounce) { | 29 | async function processVideoShare (actorAnnouncer: ActorModel, activity: ActivityAnnounce, notify: boolean) { |
25 | const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id | 30 | const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id |
26 | 31 | ||
27 | let video: VideoModel | 32 | let video: VideoModel |
@@ -63,5 +68,5 @@ async function processVideoShare (actorAnnouncer: ActorModel, activity: Activity | |||
63 | return undefined | 68 | return undefined |
64 | }) | 69 | }) |
65 | 70 | ||
66 | if (videoCreated) Notifier.Instance.notifyOnNewVideoIfNeeded(video) | 71 | if (videoCreated && notify) Notifier.Instance.notifyOnNewVideoIfNeeded(video) |
67 | } | 72 | } |
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index 1e893cdeb..a979771b6 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts | |||
@@ -12,17 +12,22 @@ import { Notifier } from '../../notifier' | |||
12 | import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' | 12 | import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' |
13 | import { createOrUpdateVideoPlaylist } from '../playlist' | 13 | import { createOrUpdateVideoPlaylist } from '../playlist' |
14 | import { VideoModel } from '../../../models/video/video' | 14 | import { VideoModel } from '../../../models/video/video' |
15 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
15 | 16 | ||
16 | async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) { | 17 | async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) { |
18 | const { activity, byActor } = options | ||
19 | |||
20 | // Only notify if it is not from a fetcher job | ||
21 | const notify = options.fromFetch !== true | ||
17 | const activityObject = activity.object | 22 | const activityObject = activity.object |
18 | const activityType = activityObject.type | 23 | const activityType = activityObject.type |
19 | 24 | ||
20 | if (activityType === 'Video') { | 25 | if (activityType === 'Video') { |
21 | return processCreateVideo(activity) | 26 | return processCreateVideo(activity, notify) |
22 | } | 27 | } |
23 | 28 | ||
24 | if (activityType === 'Note') { | 29 | if (activityType === 'Note') { |
25 | return retryTransactionWrapper(processCreateVideoComment, activity, byActor) | 30 | return retryTransactionWrapper(processCreateVideoComment, activity, byActor, notify) |
26 | } | 31 | } |
27 | 32 | ||
28 | if (activityType === 'CacheFile') { | 33 | if (activityType === 'CacheFile') { |
@@ -45,12 +50,12 @@ export { | |||
45 | 50 | ||
46 | // --------------------------------------------------------------------------- | 51 | // --------------------------------------------------------------------------- |
47 | 52 | ||
48 | async function processCreateVideo (activity: ActivityCreate) { | 53 | async function processCreateVideo (activity: ActivityCreate, notify: boolean) { |
49 | const videoToCreateData = activity.object as VideoTorrentObject | 54 | const videoToCreateData = activity.object as VideoTorrentObject |
50 | 55 | ||
51 | const { video, created } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoToCreateData }) | 56 | const { video, created } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoToCreateData }) |
52 | 57 | ||
53 | if (created) Notifier.Instance.notifyOnNewVideoIfNeeded(video) | 58 | if (created && notify) Notifier.Instance.notifyOnNewVideoIfNeeded(video) |
54 | 59 | ||
55 | return video | 60 | return video |
56 | } | 61 | } |
@@ -71,7 +76,7 @@ async function processCreateCacheFile (activity: ActivityCreate, byActor: ActorM | |||
71 | } | 76 | } |
72 | } | 77 | } |
73 | 78 | ||
74 | async function processCreateVideoComment (activity: ActivityCreate, byActor: ActorModel) { | 79 | async function processCreateVideoComment (activity: ActivityCreate, byActor: ActorModel, notify: boolean) { |
75 | const commentObject = activity.object as VideoCommentObject | 80 | const commentObject = activity.object as VideoCommentObject |
76 | const byAccount = byActor.Account | 81 | const byAccount = byActor.Account |
77 | 82 | ||
@@ -99,7 +104,7 @@ async function processCreateVideoComment (activity: ActivityCreate, byActor: Act | |||
99 | await forwardVideoRelatedActivity(activity, undefined, exceptions, video) | 104 | await forwardVideoRelatedActivity(activity, undefined, exceptions, video) |
100 | } | 105 | } |
101 | 106 | ||
102 | if (created === true) Notifier.Instance.notifyOnNewComment(comment) | 107 | if (created && notify) Notifier.Instance.notifyOnNewComment(comment) |
103 | } | 108 | } |
104 | 109 | ||
105 | async function processCreatePlaylist (activity: ActivityCreate, byActor: ActorModel) { | 110 | async function processCreatePlaylist (activity: ActivityCreate, byActor: ActorModel) { |
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts index 6f10a50bd..845a7b249 100644 --- a/server/lib/activitypub/process/process-delete.ts +++ b/server/lib/activitypub/process/process-delete.ts | |||
@@ -9,8 +9,11 @@ import { VideoChannelModel } from '../../../models/video/video-channel' | |||
9 | import { VideoCommentModel } from '../../../models/video/video-comment' | 9 | import { VideoCommentModel } from '../../../models/video/video-comment' |
10 | import { forwardVideoRelatedActivity } from '../send/utils' | 10 | import { forwardVideoRelatedActivity } from '../send/utils' |
11 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | 11 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' |
12 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
13 | |||
14 | async function processDeleteActivity (options: APProcessorOptions<ActivityDelete>) { | ||
15 | const { activity, byActor } = options | ||
12 | 16 | ||
13 | async function processDeleteActivity (activity: ActivityDelete, byActor: ActorModel) { | ||
14 | const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id | 17 | const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id |
15 | 18 | ||
16 | if (activity.actor === objectUrl) { | 19 | if (activity.actor === objectUrl) { |
diff --git a/server/lib/activitypub/process/process-dislike.ts b/server/lib/activitypub/process/process-dislike.ts index f06269f8b..a457e5f17 100644 --- a/server/lib/activitypub/process/process-dislike.ts +++ b/server/lib/activitypub/process/process-dislike.ts | |||
@@ -7,8 +7,10 @@ import { ActorModel } from '../../../models/activitypub/actor' | |||
7 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | 7 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' |
8 | import { forwardVideoRelatedActivity } from '../send/utils' | 8 | import { forwardVideoRelatedActivity } from '../send/utils' |
9 | import { getVideoDislikeActivityPubUrl } from '../url' | 9 | import { getVideoDislikeActivityPubUrl } from '../url' |
10 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
10 | 11 | ||
11 | async function processDislikeActivity (activity: ActivityCreate | ActivityDislike, byActor: ActorModel) { | 12 | async function processDislikeActivity (options: APProcessorOptions<ActivityCreate | ActivityDislike>) { |
13 | const { activity, byActor } = options | ||
12 | return retryTransactionWrapper(processDislike, activity, byActor) | 14 | return retryTransactionWrapper(processDislike, activity, byActor) |
13 | } | 15 | } |
14 | 16 | ||
diff --git a/server/lib/activitypub/process/process-flag.ts b/server/lib/activitypub/process/process-flag.ts index 8faab051e..532545e58 100644 --- a/server/lib/activitypub/process/process-flag.ts +++ b/server/lib/activitypub/process/process-flag.ts | |||
@@ -8,8 +8,10 @@ import { VideoAbuseModel } from '../../../models/video/video-abuse' | |||
8 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | 8 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' |
9 | import { Notifier } from '../../notifier' | 9 | import { Notifier } from '../../notifier' |
10 | import { getAPId } from '../../../helpers/activitypub' | 10 | import { getAPId } from '../../../helpers/activitypub' |
11 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
11 | 12 | ||
12 | async function processFlagActivity (activity: ActivityCreate | ActivityFlag, byActor: ActorModel) { | 13 | async function processFlagActivity (options: APProcessorOptions<ActivityCreate | ActivityFlag>) { |
14 | const { activity, byActor } = options | ||
13 | return retryTransactionWrapper(processCreateVideoAbuse, activity, byActor) | 15 | return retryTransactionWrapper(processCreateVideoAbuse, activity, byActor) |
14 | } | 16 | } |
15 | 17 | ||
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts index ed16ba172..8fe9975f6 100644 --- a/server/lib/activitypub/process/process-follow.ts +++ b/server/lib/activitypub/process/process-follow.ts | |||
@@ -9,8 +9,10 @@ import { Notifier } from '../../notifier' | |||
9 | import { getAPId } from '../../../helpers/activitypub' | 9 | import { getAPId } from '../../../helpers/activitypub' |
10 | import { getServerActor } from '../../../helpers/utils' | 10 | import { getServerActor } from '../../../helpers/utils' |
11 | import { CONFIG } from '../../../initializers/config' | 11 | import { CONFIG } from '../../../initializers/config' |
12 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
12 | 13 | ||
13 | async function processFollowActivity (activity: ActivityFollow, byActor: ActorModel) { | 14 | async function processFollowActivity (options: APProcessorOptions<ActivityFollow>) { |
15 | const { activity, byActor } = options | ||
14 | const activityObject = getAPId(activity.object) | 16 | const activityObject = getAPId(activity.object) |
15 | 17 | ||
16 | return retryTransactionWrapper(processFollow, byActor, activityObject) | 18 | return retryTransactionWrapper(processFollow, byActor, activityObject) |
diff --git a/server/lib/activitypub/process/process-like.ts b/server/lib/activitypub/process/process-like.ts index bba54a19b..706e63c41 100644 --- a/server/lib/activitypub/process/process-like.ts +++ b/server/lib/activitypub/process/process-like.ts | |||
@@ -7,8 +7,10 @@ import { forwardVideoRelatedActivity } from '../send/utils' | |||
7 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | 7 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' |
8 | import { getVideoLikeActivityPubUrl } from '../url' | 8 | import { getVideoLikeActivityPubUrl } from '../url' |
9 | import { getAPId } from '../../../helpers/activitypub' | 9 | import { getAPId } from '../../../helpers/activitypub' |
10 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
10 | 11 | ||
11 | async function processLikeActivity (activity: ActivityLike, byActor: ActorModel) { | 12 | async function processLikeActivity (options: APProcessorOptions<ActivityLike>) { |
13 | const { activity, byActor } = options | ||
12 | return retryTransactionWrapper(processLikeVideo, byActor, activity) | 14 | return retryTransactionWrapper(processLikeVideo, byActor, activity) |
13 | } | 15 | } |
14 | 16 | ||
diff --git a/server/lib/activitypub/process/process-reject.ts b/server/lib/activitypub/process/process-reject.ts index 709a65096..9181906b4 100644 --- a/server/lib/activitypub/process/process-reject.ts +++ b/server/lib/activitypub/process/process-reject.ts | |||
@@ -2,8 +2,10 @@ import { ActivityReject } from '../../../../shared/models/activitypub/activity' | |||
2 | import { sequelizeTypescript } from '../../../initializers' | 2 | import { sequelizeTypescript } from '../../../initializers' |
3 | import { ActorModel } from '../../../models/activitypub/actor' | 3 | import { ActorModel } from '../../../models/activitypub/actor' |
4 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 4 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
5 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
5 | 6 | ||
6 | async function processRejectActivity (activity: ActivityReject, targetActor: ActorModel, inboxActor?: ActorModel) { | 7 | async function processRejectActivity (options: APProcessorOptions<ActivityReject>) { |
8 | const { byActor: targetActor, inboxActor } = options | ||
7 | if (inboxActor === undefined) throw new Error('Need to reject on explicit inbox.') | 9 | if (inboxActor === undefined) throw new Error('Need to reject on explicit inbox.') |
8 | 10 | ||
9 | return processReject(inboxActor, targetActor) | 11 | return processReject(inboxActor, targetActor) |
diff --git a/server/lib/activitypub/process/process-undo.ts b/server/lib/activitypub/process/process-undo.ts index 692c51904..7a0f90adf 100644 --- a/server/lib/activitypub/process/process-undo.ts +++ b/server/lib/activitypub/process/process-undo.ts | |||
@@ -10,8 +10,10 @@ import { forwardVideoRelatedActivity } from '../send/utils' | |||
10 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | 10 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' |
11 | import { VideoShareModel } from '../../../models/video/video-share' | 11 | import { VideoShareModel } from '../../../models/video/video-share' |
12 | import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' | 12 | import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' |
13 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
13 | 14 | ||
14 | async function processUndoActivity (activity: ActivityUndo, byActor: ActorModel) { | 15 | async function processUndoActivity (options: APProcessorOptions<ActivityUndo>) { |
16 | const { activity, byActor } = options | ||
15 | const activityToUndo = activity.object | 17 | const activityToUndo = activity.object |
16 | 18 | ||
17 | if (activityToUndo.type === 'Like') { | 19 | if (activityToUndo.type === 'Like') { |
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts index 71a16dacc..1e11dd1fd 100644 --- a/server/lib/activitypub/process/process-update.ts +++ b/server/lib/activitypub/process/process-update.ts | |||
@@ -14,8 +14,11 @@ import { createOrUpdateCacheFile } from '../cache-file' | |||
14 | import { forwardVideoRelatedActivity } from '../send/utils' | 14 | import { forwardVideoRelatedActivity } from '../send/utils' |
15 | import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' | 15 | import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' |
16 | import { createOrUpdateVideoPlaylist } from '../playlist' | 16 | import { createOrUpdateVideoPlaylist } from '../playlist' |
17 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
18 | |||
19 | async function processUpdateActivity (options: APProcessorOptions<ActivityUpdate>) { | ||
20 | const { activity, byActor } = options | ||
17 | 21 | ||
18 | async function processUpdateActivity (activity: ActivityUpdate, byActor: ActorModel) { | ||
19 | const objectType = activity.object.type | 22 | const objectType = activity.object.type |
20 | 23 | ||
21 | if (objectType === 'Video') { | 24 | if (objectType === 'Video') { |
diff --git a/server/lib/activitypub/process/process-view.ts b/server/lib/activitypub/process/process-view.ts index 8f66d3630..0170b74f4 100644 --- a/server/lib/activitypub/process/process-view.ts +++ b/server/lib/activitypub/process/process-view.ts | |||
@@ -3,8 +3,10 @@ import { getOrCreateVideoAndAccountAndChannel } from '../videos' | |||
3 | import { forwardVideoRelatedActivity } from '../send/utils' | 3 | import { forwardVideoRelatedActivity } from '../send/utils' |
4 | import { Redis } from '../../redis' | 4 | import { Redis } from '../../redis' |
5 | import { ActivityCreate, ActivityView, ViewObject } from '../../../../shared/models/activitypub' | 5 | import { ActivityCreate, ActivityView, ViewObject } from '../../../../shared/models/activitypub' |
6 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
6 | 7 | ||
7 | async function processViewActivity (activity: ActivityView | ActivityCreate, byActor: ActorModel) { | 8 | async function processViewActivity (options: APProcessorOptions<ActivityCreate | ActivityView>) { |
9 | const { activity, byActor } = options | ||
8 | return processCreateView(activity, byActor) | 10 | return processCreateView(activity, byActor) |
9 | } | 11 | } |
10 | 12 | ||
diff --git a/server/lib/activitypub/process/process.ts b/server/lib/activitypub/process/process.ts index 9dd241402..f4a92e341 100644 --- a/server/lib/activitypub/process/process.ts +++ b/server/lib/activitypub/process/process.ts | |||
@@ -15,8 +15,9 @@ import { getOrCreateActorAndServerAndModel } from '../actor' | |||
15 | import { processDislikeActivity } from './process-dislike' | 15 | import { processDislikeActivity } from './process-dislike' |
16 | import { processFlagActivity } from './process-flag' | 16 | import { processFlagActivity } from './process-flag' |
17 | import { processViewActivity } from './process-view' | 17 | import { processViewActivity } from './process-view' |
18 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
18 | 19 | ||
19 | const processActivity: { [ P in ActivityType ]: (activity: Activity, byActor: ActorModel, inboxActor?: ActorModel) => Promise<any> } = { | 20 | const processActivity: { [ P in ActivityType ]: (options: APProcessorOptions<Activity>) => Promise<any> } = { |
20 | Create: processCreateActivity, | 21 | Create: processCreateActivity, |
21 | Update: processUpdateActivity, | 22 | Update: processUpdateActivity, |
22 | Delete: processDeleteActivity, | 23 | Delete: processDeleteActivity, |
@@ -37,11 +38,15 @@ async function processActivities ( | |||
37 | signatureActor?: ActorModel | 38 | signatureActor?: ActorModel |
38 | inboxActor?: ActorModel | 39 | inboxActor?: ActorModel |
39 | outboxUrl?: string | 40 | outboxUrl?: string |
40 | } = {}) { | 41 | fromFetch?: boolean |
42 | } = {} | ||
43 | ) { | ||
44 | const { outboxUrl, signatureActor, inboxActor, fromFetch = false } = options | ||
45 | |||
41 | const actorsCache: { [ url: string ]: ActorModel } = {} | 46 | const actorsCache: { [ url: string ]: ActorModel } = {} |
42 | 47 | ||
43 | for (const activity of activities) { | 48 | for (const activity of activities) { |
44 | if (!options.signatureActor && [ 'Create', 'Announce', 'Like' ].includes(activity.type) === false) { | 49 | if (!signatureActor && [ 'Create', 'Announce', 'Like' ].includes(activity.type) === false) { |
45 | logger.error('Cannot process activity %s (type: %s) without the actor signature.', activity.id, activity.type) | 50 | logger.error('Cannot process activity %s (type: %s) without the actor signature.', activity.id, activity.type) |
46 | continue | 51 | continue |
47 | } | 52 | } |
@@ -49,17 +54,17 @@ async function processActivities ( | |||
49 | const actorUrl = getAPId(activity.actor) | 54 | const actorUrl = getAPId(activity.actor) |
50 | 55 | ||
51 | // When we fetch remote data, we don't have signature | 56 | // When we fetch remote data, we don't have signature |
52 | if (options.signatureActor && actorUrl !== options.signatureActor.url) { | 57 | if (signatureActor && actorUrl !== signatureActor.url) { |
53 | logger.warn('Signature mismatch between %s and %s, skipping.', actorUrl, options.signatureActor.url) | 58 | logger.warn('Signature mismatch between %s and %s, skipping.', actorUrl, signatureActor.url) |
54 | continue | 59 | continue |
55 | } | 60 | } |
56 | 61 | ||
57 | if (options.outboxUrl && checkUrlsSameHost(options.outboxUrl, actorUrl) !== true) { | 62 | if (outboxUrl && checkUrlsSameHost(outboxUrl, actorUrl) !== true) { |
58 | logger.warn('Host mismatch between outbox URL %s and actor URL %s, skipping.', options.outboxUrl, actorUrl) | 63 | logger.warn('Host mismatch between outbox URL %s and actor URL %s, skipping.', outboxUrl, actorUrl) |
59 | continue | 64 | continue |
60 | } | 65 | } |
61 | 66 | ||
62 | const byActor = options.signatureActor || actorsCache[actorUrl] || await getOrCreateActorAndServerAndModel(actorUrl) | 67 | const byActor = signatureActor || actorsCache[actorUrl] || await getOrCreateActorAndServerAndModel(actorUrl) |
63 | actorsCache[actorUrl] = byActor | 68 | actorsCache[actorUrl] = byActor |
64 | 69 | ||
65 | const activityProcessor = processActivity[activity.type] | 70 | const activityProcessor = processActivity[activity.type] |
@@ -69,7 +74,7 @@ async function processActivities ( | |||
69 | } | 74 | } |
70 | 75 | ||
71 | try { | 76 | try { |
72 | await activityProcessor(activity, byActor, options.inboxActor) | 77 | await activityProcessor({ activity, byActor, inboxActor: inboxActor, fromFetch }) |
73 | } catch (err) { | 78 | } catch (err) { |
74 | logger.warn('Cannot process activity %s.', activity.type, { err }) | 79 | logger.warn('Cannot process activity %s.', activity.type, { err }) |
75 | } | 80 | } |