aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process/process-create.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/process/process-create.ts')
-rw-r--r--server/lib/activitypub/process/process-create.ts19
1 files changed, 7 insertions, 12 deletions
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts
index cefe89db0..214e14546 100644
--- a/server/lib/activitypub/process/process-create.ts
+++ b/server/lib/activitypub/process/process-create.ts
@@ -12,6 +12,9 @@ import { getOrCreateVideoAndAccountAndChannel } from '../videos'
12import { forwardVideoRelatedActivity } from '../send/utils' 12import { forwardVideoRelatedActivity } from '../send/utils'
13import { Redis } from '../../redis' 13import { Redis } from '../../redis'
14import { createOrUpdateCacheFile } from '../cache-file' 14import { createOrUpdateCacheFile } from '../cache-file'
15import { immutableAssign } from '../../../tests/utils'
16import { getVideoDislikeActivityPubUrl } from '../url'
17import { VideoModel } from '../../../models/video/video'
15 18
16async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) { 19async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) {
17 const activityObject = activity.object 20 const activityObject = activity.object
@@ -65,9 +68,10 @@ async function processCreateDislike (byActor: ActorModel, activity: ActivityCrea
65 videoId: video.id, 68 videoId: video.id,
66 accountId: byAccount.id 69 accountId: byAccount.id
67 } 70 }
71
68 const [ , created ] = await AccountVideoRateModel.findOrCreate({ 72 const [ , created ] = await AccountVideoRateModel.findOrCreate({
69 where: rate, 73 where: rate,
70 defaults: rate, 74 defaults: immutableAssign(rate, { url: getVideoDislikeActivityPubUrl(byActor, video) }),
71 transaction: t 75 transaction: t
72 }) 76 })
73 if (created === true) await video.increment('dislikes', { transaction: t }) 77 if (created === true) await video.increment('dislikes', { transaction: t })
@@ -84,19 +88,10 @@ async function processCreateDislike (byActor: ActorModel, activity: ActivityCrea
84async function processCreateView (byActor: ActorModel, activity: ActivityCreate) { 88async function processCreateView (byActor: ActorModel, activity: ActivityCreate) {
85 const view = activity.object as ViewObject 89 const view = activity.object as ViewObject
86 90
87 const options = { 91 const video = await VideoModel.loadByUrl(view.object)
88 videoObject: view.object, 92 if (!video || video.isOwned() === false) return
89 fetchType: 'only-video' as 'only-video'
90 }
91 const { video } = await getOrCreateVideoAndAccountAndChannel(options)
92 93
93 await Redis.Instance.addVideoView(video.id) 94 await Redis.Instance.addVideoView(video.id)
94
95 if (video.isOwned()) {
96 // Don't resend the activity to the sender
97 const exceptions = [ byActor ]
98 await forwardVideoRelatedActivity(activity, undefined, exceptions, video)
99 }
100} 95}
101 96
102async function processCacheFile (byActor: ActorModel, activity: ActivityCreate) { 97async function processCacheFile (byActor: ActorModel, activity: ActivityCreate) {