From a7d647c4403f8774106f485e8d9323158454e111 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 15 Dec 2017 17:34:38 +0100 Subject: Add dirty migration :/ --- server/lib/activitypub/share.ts | 16 +++++++++++++--- .../video-file-optimizer-handler.ts | 4 ++-- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'server/lib') diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts index f79c4e532..fb01368ec 100644 --- a/server/lib/activitypub/share.ts +++ b/server/lib/activitypub/share.ts @@ -4,17 +4,27 @@ import { VideoModel } from '../../models/video/video' import { VideoShareModel } from '../../models/video/video-share' import { sendVideoAnnounceToFollowers } from './send' -async function shareVideoByServer (video: VideoModel, t: Transaction) { +async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) { const serverActor = await getServerActor() - await VideoShareModel.create({ + const serverShare = VideoShareModel.create({ actorId: serverActor.id, videoId: video.id }, { transaction: t }) + const videoChannelShare = VideoShareModel.create({ + actorId: video.VideoChannel.actorId, + videoId: video.id + }, { transaction: t }) + + await Promise.all([ + serverShare, + videoChannelShare + ]) + return sendVideoAnnounceToFollowers(serverActor, video, t) } export { - shareVideoByServer + shareVideoByServerAndChannel } diff --git a/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts b/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts index 7df048006..cde4948de 100644 --- a/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts +++ b/server/lib/jobs/transcoding-job-scheduler/video-file-optimizer-handler.ts @@ -2,7 +2,7 @@ import * as Bluebird from 'bluebird' import { computeResolutionsToTranscode, logger } from '../../../helpers' import { sequelizeTypescript } from '../../../initializers' import { VideoModel } from '../../../models/video/video' -import { shareVideoByServer } from '../../activitypub' +import { shareVideoByServerAndChannel } from '../../activitypub' import { sendCreateVideo } from '../../activitypub/send' import { JobScheduler } from '../job-scheduler' import { TranscodingJobPayload } from './transcoding-job-scheduler' @@ -38,7 +38,7 @@ async function onSuccess (jobId: number, video: VideoModel, jobScheduler: JobSch // Now we'll add the video's meta data to our followers await sendCreateVideo(video, undefined) // TODO: share by channel - await shareVideoByServer(video, undefined) + await shareVideoByServerAndChannel(video, undefined) const originalFileHeight = await videoDatabase.getOriginalFileHeight() -- cgit v1.2.3