X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fjob-queue%2Fhandlers%2Factivitypub-follow.ts;h=82c95be800292f2000db7afda50ad0715eb72288;hb=d487a997c80fafe6067016c6cd8e8afd6141baa3;hp=af7c8a8383afe42bcdcadb7e6e56242f1dcb745b;hpb=8c559fad1e1c4c2ab7f1388c73200aa4c6256d74;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/job-queue/handlers/activitypub-follow.ts b/server/lib/job-queue/handlers/activitypub-follow.ts index af7c8a838..82c95be80 100644 --- a/server/lib/job-queue/handlers/activitypub-follow.ts +++ b/server/lib/job-queue/handlers/activitypub-follow.ts @@ -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) @@ -48,7 +48,7 @@ export { async function follow (fromActor: MActor, targetActor: MActorFull, isAutoFollow = false) { if (fromActor.id === targetActor.id) { - throw new Error('Follower is the same than target actor.') + throw new Error('Follower is the same as target actor.') } // Same server, direct accept @@ -62,6 +62,7 @@ async function follow (fromActor: MActor, targetActor: MActorFull, isAutoFollow }, defaults: { state, + url: getLocalActorFollowActivityPubUrl(fromActor, targetActor), actorId: fromActor.id, targetActorId: targetActor.id },