]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/job-queue/handlers/activitypub-follow.ts
Import in private, and then set the chosen privacy
[github/Chocobozzz/PeerTube.git] / server / lib / job-queue / handlers / activitypub-follow.ts
index 4a7cda0a2ba74e216b3d76aa1a769833f604e884..82c95be800292f2000db7afda50ad0715eb72288 100644 (file)
@@ -10,14 +10,9 @@ import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
 import { ActorModel } from '../../../models/activitypub/actor'
 import { Notifier } from '../../notifier'
 import { sequelizeTypescript } from '../../../initializers/database'
-import { MActor, MActorFollowActors, MActorFull } from '../../../typings/models'
-
-export type ActivitypubFollowPayload = {
-  followerActorId: number
-  name: string
-  host: string
-  isAutoFollow?: boolean
-}
+import { MActor, MActorFollowActors, MActorFull } from '../../../types/models'
+import { ActivitypubFollowPayload } from '@shared/models'
+import { getLocalActorFollowActivityPubUrl } from '@server/lib/activitypub/url'
 
 async function processActivityPubFollow (job: Bull.Job) {
   const payload = job.data as ActivitypubFollowPayload
@@ -34,6 +29,11 @@ async function processActivityPubFollow (job: Bull.Job) {
     targetActor = await getOrCreateActorAndServerAndModel(actorUrl, 'all')
   }
 
+  if (payload.assertIsChannel && !targetActor.VideoChannel) {
+    logger.warn('Do not follow %s@%s because it is not a channel.', payload.name, host)
+    return
+  }
+
   const fromActor = await ActorModel.load(payload.followerActorId)
 
   return retryTransactionWrapper(follow, fromActor, targetActor, payload.isAutoFollow)
@@ -62,6 +62,7 @@ async function follow (fromActor: MActor, targetActor: MActorFull, isAutoFollow
       },
       defaults: {
         state,
+        url: getLocalActorFollowActivityPubUrl(fromActor, targetActor),
         actorId: fromActor.id,
         targetActorId: targetActor.id
       },