X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Factivitypub%2Fshare.ts;h=1f8a8f3c48c872d0ac1568267e63d6883146defb;hb=92315d979c3f424d81f8fca3c8831d81e4e2a6d6;hp=fdca9bed75c3e14c487f1af3164f0544cce99cac;hpb=00aab0666c6f772548c160fdfa871a8843b88f37;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts index fdca9bed7..1f8a8f3c4 100644 --- a/server/lib/activitypub/share.ts +++ b/server/lib/activitypub/share.ts @@ -1,19 +1,18 @@ import { Transaction } from 'sequelize' -import { VideoPrivacy } from '../../../shared/models/videos' -import { getServerActor } from '../../helpers/utils' import { VideoShareModel } from '../../models/video/video-share' import { sendUndoAnnounce, sendVideoAnnounce } from './send' -import { getVideoAnnounceActivityPubUrl } from './url' +import { getLocalVideoAnnounceActivityPubUrl } from './url' import * as Bluebird from 'bluebird' import { doRequest } from '../../helpers/requests' import { getOrCreateActorAndServerAndModel } from './actor' import { logger } from '../../helpers/logger' import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants' import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub' -import { MChannelActor, MChannelActorLight, MVideo, MVideoAccountLight, MVideoId } from '../../typings/models/video' +import { MChannelActorLight, MVideo, MVideoAccountLight, MVideoId } from '../../types/models/video' +import { getServerActor } from '@server/models/application/application' async function shareVideoByServerAndChannel (video: MVideoAccountLight, t: Transaction) { - if (video.privacy === VideoPrivacy.PRIVATE) return undefined + if (!video.hasPrivacyForFederation()) return undefined return Promise.all([ shareByServer(video, t), @@ -37,7 +36,7 @@ async function addVideoShares (shareUrls: string[], video: MVideoId) { await Bluebird.map(shareUrls, async shareUrl => { try { // Fetch url - const { body } = await doRequest({ + const { body } = await doRequest({ uri: shareUrl, json: true, activityPub: true @@ -75,7 +74,7 @@ export { async function shareByServer (video: MVideo, t: Transaction) { const serverActor = await getServerActor() - const serverShareUrl = getVideoAnnounceActivityPubUrl(serverActor, video) + const serverShareUrl = getLocalVideoAnnounceActivityPubUrl(serverActor, video) const [ serverShare ] = await VideoShareModel.findOrCreate({ defaults: { actorId: serverActor.id, @@ -92,7 +91,7 @@ async function shareByServer (video: MVideo, t: Transaction) { } async function shareByVideoChannel (video: MVideoAccountLight, t: Transaction) { - const videoChannelShareUrl = getVideoAnnounceActivityPubUrl(video.VideoChannel.Actor, video) + const videoChannelShareUrl = getLocalVideoAnnounceActivityPubUrl(video.VideoChannel.Actor, video) const [ videoChannelShare ] = await VideoShareModel.findOrCreate({ defaults: { actorId: video.VideoChannel.actorId,