From 528a9efa8272532bbd0dafc35c3e05e57c50f61e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sat, 18 Jun 2016 16:13:54 +0200 Subject: Try to make a better communication (between pods) module --- server/controllers/api/v1/videos.js | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'server/controllers/api/v1/videos.js') diff --git a/server/controllers/api/v1/videos.js b/server/controllers/api/v1/videos.js index 5449cbcfa..2edb31122 100644 --- a/server/controllers/api/v1/videos.js +++ b/server/controllers/api/v1/videos.js @@ -3,8 +3,6 @@ const async = require('async') const config = require('config') const express = require('express') -const fs = require('fs') -const path = require('path') const multer = require('multer') const constants = require('../../../initializers/constants') @@ -46,7 +44,6 @@ const storage = multer.diskStorage({ }) const reqFiles = multer({ storage: storage }).fields([{ name: 'videofile', maxCount: 1 }]) -const thumbnailsDir = path.join(__dirname, '..', '..', '..', '..', config.get('storage.thumbnails')) router.get('/', reqValidatorPagination.pagination, @@ -127,34 +124,25 @@ function addVideo (req, res, next) { return callback(err) } - return callback(null, torrent, thumbnailName, videoData, insertedVideo) + return callback(null, insertedVideo) }) }, - function getThumbnailBase64 (torrent, thumbnailName, videoData, insertedVideo, callback) { - videoData.createdDate = insertedVideo.createdDate - - fs.readFile(thumbnailsDir + thumbnailName, function (err, thumbnailData) { + function sendToFriends (insertedVideo, callback) { + videos.convertVideoToRemote(insertedVideo, function (err, remoteVideo) { if (err) { // TODO unseed the video // TODO remove thumbnail - // TODO: remove video - logger.error('Cannot read the thumbnail of the video') + // TODO delete from DB + logger.error('Cannot convert video to remote.') return callback(err) } - return callback(null, videoData, thumbnailData) - }) - }, - - function sendToFriends (videoData, thumbnailData, callback) { - // Set the image in base64 - videoData.thumbnailBase64 = new Buffer(thumbnailData).toString('base64') + // Now we'll add the video's meta data to our friends + friends.addVideoToFriends(remoteVideo) - // Now we'll add the video's meta data to our friends - friends.addVideoToFriends(videoData) - - return callback(null) + return callback(null) + }) } ], function andFinally (err) { -- cgit v1.2.3