From 54141398354e6e7b94aa3065a705a1251390111c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 20 Nov 2017 09:43:39 +0100 Subject: Refractor activity pub lib/helpers --- server/controllers/api/videos/channel.ts | 6 +++--- server/controllers/api/videos/index.ts | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'server/controllers/api/videos') diff --git a/server/controllers/api/videos/channel.ts b/server/controllers/api/videos/channel.ts index 8f3df2550..ce2656e71 100644 --- a/server/controllers/api/videos/channel.ts +++ b/server/controllers/api/videos/channel.ts @@ -17,7 +17,7 @@ import { videoChannelsUpdateValidator } from '../../../middlewares' import { AccountInstance, VideoChannelInstance } from '../../../models' -import { sendUpdateVideoChannel } from '../../../lib/activitypub/send-request' +import { sendUpdateVideoChannel } from '../../../lib/activitypub/send/send-update' const videoChannelRouter = express.Router() @@ -128,9 +128,9 @@ async function updateVideoChannel (req: express.Request, res: express.Response) if (videoChannelInfoToUpdate.name !== undefined) videoChannelInstance.set('name', videoChannelInfoToUpdate.name) if (videoChannelInfoToUpdate.description !== undefined) videoChannelInstance.set('description', videoChannelInfoToUpdate.description) - await videoChannelInstance.save(sequelizeOptions) + const videoChannelInstanceUpdated = await videoChannelInstance.save(sequelizeOptions) - await sendUpdateVideoChannel(videoChannelInstance, t) + await sendUpdateVideoChannel(videoChannelInstanceUpdated, t) }) logger.info('Video channel with name %s and uuid %s updated.', videoChannelInstance.name, videoChannelInstance.uuid) diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 22a88620a..8c9b0aa50 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -12,10 +12,11 @@ import { resetSequelizeInstance, retryTransactionWrapper } from '../../../helpers' -import { getActivityPubUrl, shareVideoByServer } from '../../../helpers/activitypub' +import { getVideoActivityPubUrl, shareVideoByServer } from '../../../helpers/activitypub' import { CONFIG, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_MIMETYPE_EXT, VIDEO_PRIVACIES } from '../../../initializers' import { database as db } from '../../../initializers/database' -import { sendAddVideo, sendUpdateVideo } from '../../../lib/activitypub/send-request' +import { sendAddVideo } from '../../../lib/activitypub/send/send-add' +import { sendUpdateVideo } from '../../../lib/activitypub/send/send-update' import { transcodingJobScheduler } from '../../../lib/jobs/transcoding-job-scheduler/transcoding-job-scheduler' import { asyncMiddleware, @@ -175,7 +176,7 @@ async function addVideo (req: express.Request, res: express.Response, videoPhysi channelId: res.locals.videoChannel.id } const video = db.Video.build(videoData) - video.url = getActivityPubUrl('video', video.uuid) + video.url = getVideoActivityPubUrl(video) const videoFilePath = join(CONFIG.STORAGE.VIDEOS_DIR, videoPhysicalFile.filename) const videoFileHeight = await getVideoFileHeight(videoFilePath) @@ -274,7 +275,7 @@ async function updateVideo (req: express.Request, res: express.Response) { if (videoInfoToUpdate.privacy !== undefined) videoInstance.set('privacy', videoInfoToUpdate.privacy) if (videoInfoToUpdate.description !== undefined) videoInstance.set('description', videoInfoToUpdate.description) - await videoInstance.save(sequelizeOptions) + const videoInstanceUpdated = await videoInstance.save(sequelizeOptions) if (videoInfoToUpdate.tags) { const tagInstances = await db.Tag.findOrCreateTags(videoInfoToUpdate.tags, t) @@ -285,7 +286,7 @@ async function updateVideo (req: express.Request, res: express.Response) { // Now we'll update the video's meta data to our friends if (wasPrivateVideo === false) { - await sendUpdateVideo(videoInstance, t) + await sendUpdateVideo(videoInstanceUpdated, t) } // Video is not private anymore, send a create action to remote servers -- cgit v1.2.3