From 276d03ed1a469fd4e3579f92392b6f9a1567d1ca Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 21 Feb 2018 10:07:02 +0100 Subject: Unlisted videos are not displayed on Mastodon now --- server/lib/activitypub/process/process-update.ts | 2 +- server/lib/activitypub/send/misc.ts | 4 ++-- server/lib/activitypub/videos.ts | 20 +++++--------------- 3 files changed, 8 insertions(+), 18 deletions(-) (limited to 'server/lib') diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts index 566e5938b..24e5589d4 100644 --- a/server/lib/activitypub/process/process-update.ts +++ b/server/lib/activitypub/process/process-update.ts @@ -71,7 +71,7 @@ async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) { throw new Error('Account ' + actor.url + ' does not own video channel ' + videoChannel.Actor.url) } - const videoData = await videoActivityObjectToDBAttributes(videoChannel, videoAttributesToUpdate, activity.to, activity.cc) + const videoData = await videoActivityObjectToDBAttributes(videoChannel, videoAttributesToUpdate, activity.to) videoInstance.set('name', videoData.name) videoInstance.set('uuid', videoData.uuid) videoInstance.set('url', videoData.url) diff --git a/server/lib/activitypub/send/misc.ts b/server/lib/activitypub/send/misc.ts index 7a21f0c94..607822d16 100644 --- a/server/lib/activitypub/send/misc.ts +++ b/server/lib/activitypub/send/misc.ts @@ -153,8 +153,8 @@ function buildAudience (followerInboxUrls: string[], isPublic = true) { to = [ ACTIVITY_PUB.PUBLIC ] cc = followerInboxUrls } else { // Unlisted - to = followerInboxUrls - cc = [ ACTIVITY_PUB.PUBLIC ] + to = [ ] + cc = [ ] } return { to, cc } diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index e65362190..e7b516129 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts @@ -56,11 +56,8 @@ function generateThumbnailFromUrl (video: VideoModel, icon: ActivityIconObject) async function videoActivityObjectToDBAttributes (videoChannel: VideoChannelModel, videoObject: VideoTorrentObject, - to: string[] = [], - cc: string[] = []) { - let privacy = VideoPrivacy.PRIVATE - if (to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1) privacy = VideoPrivacy.PUBLIC - else if (cc.indexOf(ACTIVITY_PUB.PUBLIC) !== -1) privacy = VideoPrivacy.UNLISTED + to: string[] = []) { + const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPrivacy.PUBLIC : VideoPrivacy.UNLISTED const duration = videoObject.duration.replace(/[^\d]+/, '') let language = null @@ -78,15 +75,8 @@ async function videoActivityObjectToDBAttributes (videoChannel: VideoChannelMode licence = parseInt(videoObject.licence.identifier, 10) } - let description = null - if (videoObject.content) { - description = videoObject.content - } - - let support = null - if (videoObject.support) { - support = videoObject.support - } + const description = videoObject.content || null + const support = videoObject.support || null return { name: videoObject.name, @@ -157,7 +147,7 @@ async function getOrCreateVideo (videoObject: VideoTorrentObject, channelActor: const videoFromDatabase = await VideoModel.loadByUUIDOrURLAndPopulateAccount(videoObject.uuid, videoObject.id, t) if (videoFromDatabase) return videoFromDatabase - const videoData = await videoActivityObjectToDBAttributes(channelActor.VideoChannel, videoObject, videoObject.to, videoObject.cc) + const videoData = await videoActivityObjectToDBAttributes(channelActor.VideoChannel, videoObject, videoObject.to) const video = VideoModel.build(videoData) // Don't block on request -- cgit v1.2.3