diff options
Diffstat (limited to 'server/lib/activitypub/process/process-create.ts')
-rw-r--r-- | server/lib/activitypub/process/process-create.ts | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index 559a0c23c..5197dac73 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts | |||
@@ -7,30 +7,28 @@ import { sequelizeTypescript } from '../../../initializers' | |||
7 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' | 7 | import { AccountVideoRateModel } from '../../../models/account/account-video-rate' |
8 | import { ActorModel } from '../../../models/activitypub/actor' | 8 | import { ActorModel } from '../../../models/activitypub/actor' |
9 | import { VideoAbuseModel } from '../../../models/video/video-abuse' | 9 | import { VideoAbuseModel } from '../../../models/video/video-abuse' |
10 | import { getOrCreateActorAndServerAndModel } from '../actor' | ||
11 | import { addVideoComment, resolveThread } from '../video-comments' | 10 | import { addVideoComment, resolveThread } from '../video-comments' |
12 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | 11 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' |
13 | import { forwardActivity, forwardVideoRelatedActivity } from '../send/utils' | 12 | import { forwardActivity, forwardVideoRelatedActivity } from '../send/utils' |
14 | import { Redis } from '../../redis' | 13 | import { Redis } from '../../redis' |
15 | import { createCacheFile } from '../cache-file' | 14 | import { createCacheFile } from '../cache-file' |
16 | 15 | ||
17 | async function processCreateActivity (activity: ActivityCreate) { | 16 | async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) { |
18 | const activityObject = activity.object | 17 | const activityObject = activity.object |
19 | const activityType = activityObject.type | 18 | const activityType = activityObject.type |
20 | const actor = await getOrCreateActorAndServerAndModel(activity.actor) | ||
21 | 19 | ||
22 | if (activityType === 'View') { | 20 | if (activityType === 'View') { |
23 | return processCreateView(actor, activity) | 21 | return processCreateView(byActor, activity) |
24 | } else if (activityType === 'Dislike') { | 22 | } else if (activityType === 'Dislike') { |
25 | return retryTransactionWrapper(processCreateDislike, actor, activity) | 23 | return retryTransactionWrapper(processCreateDislike, byActor, activity) |
26 | } else if (activityType === 'Video') { | 24 | } else if (activityType === 'Video') { |
27 | return processCreateVideo(activity) | 25 | return processCreateVideo(activity) |
28 | } else if (activityType === 'Flag') { | 26 | } else if (activityType === 'Flag') { |
29 | return retryTransactionWrapper(processCreateVideoAbuse, actor, activityObject as VideoAbuseObject) | 27 | return retryTransactionWrapper(processCreateVideoAbuse, byActor, activityObject as VideoAbuseObject) |
30 | } else if (activityType === 'Note') { | 28 | } else if (activityType === 'Note') { |
31 | return retryTransactionWrapper(processCreateVideoComment, actor, activity) | 29 | return retryTransactionWrapper(processCreateVideoComment, byActor, activity) |
32 | } else if (activityType === 'CacheFile') { | 30 | } else if (activityType === 'CacheFile') { |
33 | return retryTransactionWrapper(processCacheFile, actor, activity) | 31 | return retryTransactionWrapper(processCacheFile, byActor, activity) |
34 | } | 32 | } |
35 | 33 | ||
36 | logger.warn('Unknown activity object type %s when creating activity.', activityType, { activity: activity.id }) | 34 | logger.warn('Unknown activity object type %s when creating activity.', activityType, { activity: activity.id }) |
@@ -118,11 +116,11 @@ async function processCacheFile (byActor: ActorModel, activity: ActivityCreate) | |||
118 | } | 116 | } |
119 | } | 117 | } |
120 | 118 | ||
121 | async function processCreateVideoAbuse (actor: ActorModel, videoAbuseToCreateData: VideoAbuseObject) { | 119 | async function processCreateVideoAbuse (byActor: ActorModel, videoAbuseToCreateData: VideoAbuseObject) { |
122 | logger.debug('Reporting remote abuse for video %s.', videoAbuseToCreateData.object) | 120 | logger.debug('Reporting remote abuse for video %s.', videoAbuseToCreateData.object) |
123 | 121 | ||
124 | const account = actor.Account | 122 | const account = byActor.Account |
125 | if (!account) throw new Error('Cannot create dislike with the non account actor ' + actor.url) | 123 | if (!account) throw new Error('Cannot create dislike with the non account actor ' + byActor.url) |
126 | 124 | ||
127 | const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoAbuseToCreateData.object }) | 125 | const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoAbuseToCreateData.object }) |
128 | 126 | ||