From: Chocobozzz Date: Fri, 25 May 2018 09:17:41 +0000 (+0200) Subject: Fix cc field in classic audience X-Git-Tag: v1.0.0-beta.7~14 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=16f29007dc6ad9c539195d7a7c1cde45d626ce91;p=oweals%2Fpeertube.git Fix cc field in classic audience --- diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index 4c336f26e..f27733418 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts @@ -19,6 +19,8 @@ import { ActorModel } from '../../models/activitypub/actor' import { AvatarModel } from '../../models/avatar/avatar' import { ServerModel } from '../../models/server/server' import { VideoChannelModel } from '../../models/video/video-channel' +import { JobQueue } from '../job-queue' +import { getServerActor } from '../../helpers/utils' // Set account keys, this could be long so process after the account creation and do not block the client function setAsyncActorKeys (actor: ActorModel) { @@ -169,6 +171,21 @@ async function fetchAvatarIfExists (actorJSON: ActivityPubActor) { return undefined } +async function addFetchOutboxJob (actor: ActorModel) { + // Don't fetch ourselves + const serverActor = await getServerActor() + if (serverActor.id === actor.id) { + logger.error('Cannot fetch our own outbox!') + return undefined + } + + const payload = { + uris: [ actor.outboxUrl ] + } + + return JobQueue.Instance.createJob({ type: 'activitypub-http-fetcher', payload }) +} + export { getOrCreateActorAndServerAndModel, buildActorInstance, @@ -176,7 +193,8 @@ export { fetchActorTotalItems, fetchAvatarIfExists, updateActorInstance, - updateActorAvatarInstance + updateActorAvatarInstance, + addFetchOutboxJob } // --------------------------------------------------------------------------- diff --git a/server/lib/activitypub/fetch.ts b/server/lib/activitypub/fetch.ts deleted file mode 100644 index a8eefff80..000000000 --- a/server/lib/activitypub/fetch.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { logger } from '../../helpers/logger' -import { getServerActor } from '../../helpers/utils' -import { ActorModel } from '../../models/activitypub/actor' -import { JobQueue } from '../job-queue' - -async function addFetchOutboxJob (actor: ActorModel) { - // Don't fetch ourselves - const serverActor = await getServerActor() - if (serverActor.id === actor.id) { - logger.error('Cannot fetch our own outbox!') - return undefined - } - - const payload = { - uris: [ actor.outboxUrl ] - } - - return JobQueue.Instance.createJob({ type: 'activitypub-http-fetcher', payload }) -} - -export { - addFetchOutboxJob -} diff --git a/server/lib/activitypub/process/process-accept.ts b/server/lib/activitypub/process/process-accept.ts index c55b57820..046370b79 100644 --- a/server/lib/activitypub/process/process-accept.ts +++ b/server/lib/activitypub/process/process-accept.ts @@ -2,7 +2,7 @@ import { ActivityAccept } from '../../../../shared/models/activitypub' import { getActorUrl } from '../../../helpers/activitypub' import { ActorModel } from '../../../models/activitypub/actor' import { ActorFollowModel } from '../../../models/activitypub/actor-follow' -import { addFetchOutboxJob } from '../fetch' +import { addFetchOutboxJob } from '../actor' async function processAcceptActivity (activity: ActivityAccept, inboxActor?: ActorModel) { if (inboxActor === undefined) throw new Error('Need to accept on explicit inbox.') diff --git a/server/lib/activitypub/send/misc.ts b/server/lib/activitypub/send/misc.ts index b2d968c9c..646aa9f0a 100644 --- a/server/lib/activitypub/send/misc.ts +++ b/server/lib/activitypub/send/misc.ts @@ -139,9 +139,7 @@ async function getActorsInvolvedInVideo (video: VideoModel, t: Transaction) { } async function getAudience (actorSender: ActorModel, t: Transaction, isPublic = true) { - const followerInboxUrls = await actorSender.getFollowerSharedInboxUrls(t) - - return buildAudience(followerInboxUrls, isPublic) + return buildAudience([ actorSender.followersUrl ], isPublic) } function buildAudience (followerInboxUrls: string[], isPublic = true) {