Split types and typings
[oweals/peertube.git] / server / lib / activitypub / process / process-view.ts
index 8f66d3630ecdbea67096f6237ba65203aa55bcf0..cc26180af12994dab23f75d8973fcd8ee9e1ce1d 100644 (file)
@@ -1,10 +1,12 @@
-import { ActorModel } from '../../../models/activitypub/actor'
 import { getOrCreateVideoAndAccountAndChannel } from '../videos'
 import { forwardVideoRelatedActivity } from '../send/utils'
 import { Redis } from '../../redis'
 import { ActivityCreate, ActivityView, ViewObject } from '../../../../shared/models/activitypub'
+import { APProcessorOptions } from '../../../types/activitypub-processor.model'
+import { MActorSignature } from '../../../types/models'
 
-async function processViewActivity (activity: ActivityView | ActivityCreate, byActor: ActorModel) {
+async function processViewActivity (options: APProcessorOptions<ActivityCreate | ActivityView>) {
+  const { activity, byActor } = options
   return processCreateView(activity, byActor)
 }
 
@@ -16,12 +18,13 @@ export {
 
 // ---------------------------------------------------------------------------
 
-async function processCreateView (activity: ActivityView | ActivityCreate, byActor: ActorModel) {
+async function processCreateView (activity: ActivityView | ActivityCreate, byActor: MActorSignature) {
   const videoObject = activity.type === 'View' ? activity.object : (activity.object as ViewObject).object
 
   const options = {
-    videoObject: videoObject,
-    fetchType: 'only-video' as 'only-video'
+    videoObject,
+    fetchType: 'only-immutable-attributes' as 'only-immutable-attributes',
+    allowRefresh: false as false
   }
   const { video } = await getOrCreateVideoAndAccountAndChannel(options)