diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-05-10 21:19:24 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-05-10 21:19:24 +0200 |
commit | cbe2f7c34822b1bd3b1f8c691f79f0c29cf21f07 (patch) | |
tree | ce678124210db8b03b2a523e3b92a14cc403eeee /server/controllers/api/v1/pods.js | |
parent | f1dae018681936b556b2496b7f2d872c004cfda3 (diff) | |
download | PeerTube-cbe2f7c34822b1bd3b1f8c691f79f0c29cf21f07.tar.gz PeerTube-cbe2f7c34822b1bd3b1f8c691f79f0c29cf21f07.tar.zst PeerTube-cbe2f7c34822b1bd3b1f8c691f79f0c29cf21f07.zip |
Refractoring and add thumbnails support (without tests)
Diffstat (limited to 'server/controllers/api/v1/pods.js')
-rw-r--r-- | server/controllers/api/v1/pods.js | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/server/controllers/api/v1/pods.js b/server/controllers/api/v1/pods.js index dbe1a7372..d08b7860d 100644 --- a/server/controllers/api/v1/pods.js +++ b/server/controllers/api/v1/pods.js | |||
@@ -1,17 +1,16 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const express = require('express') | 3 | const express = require('express') |
4 | const fs = require('fs') | ||
5 | 4 | ||
6 | const logger = require('../../../helpers/logger') | 5 | const logger = require('../../../helpers/logger') |
7 | const friends = require('../../../lib/friends') | 6 | const friends = require('../../../lib/friends') |
8 | const middleware = require('../../../middlewares') | 7 | const middleware = require('../../../middlewares') |
9 | const cacheMiddleware = middleware.cache | 8 | const cacheMiddleware = middleware.cache |
10 | const peertubeCrypto = require('../../../helpers/peertubeCrypto') | ||
11 | const Pods = require('../../../models/pods') | 9 | const Pods = require('../../../models/pods') |
12 | const reqValidator = middleware.reqValidators.pods | 10 | const reqValidator = middleware.reqValidators.pods |
13 | const secureMiddleware = middleware.secure | 11 | const secureMiddleware = middleware.secure |
14 | const secureRequest = middleware.reqValidators.remote.secureRequest | 12 | const secureRequest = middleware.reqValidators.remote.secureRequest |
13 | const videos = require('../../../lib/videos') | ||
15 | const Videos = require('../../../models/videos') | 14 | const Videos = require('../../../models/videos') |
16 | 15 | ||
17 | const router = express.Router() | 16 | const router = express.Router() |
@@ -34,9 +33,12 @@ function addPods (req, res, next) { | |||
34 | Pods.add(informations, function (err) { | 33 | Pods.add(informations, function (err) { |
35 | if (err) return next(err) | 34 | if (err) return next(err) |
36 | 35 | ||
37 | Videos.addRemotes(informations.videos) | 36 | // Create the remote videos from the new pod |
37 | videos.createRemoteVideos(informations.videos, function (err) { | ||
38 | if (err) logger.error('Cannot create remote videos.', { error: err }) | ||
39 | }) | ||
38 | 40 | ||
39 | fs.readFile(peertubeCrypto.getCertDir() + 'peertube.pub', 'utf8', function (err, cert) { | 41 | friends.getMyCertificate(function (err, cert) { |
40 | if (err) { | 42 | if (err) { |
41 | logger.error('Cannot read cert file.') | 43 | logger.error('Cannot read cert file.') |
42 | return next(err) | 44 | return next(err) |
@@ -75,11 +77,20 @@ function removePods (req, res, next) { | |||
75 | Pods.remove(url, function (err) { | 77 | Pods.remove(url, function (err) { |
76 | if (err) return next(err) | 78 | if (err) return next(err) |
77 | 79 | ||
78 | Videos.removeAllRemotesOf(url, function (err) { | 80 | Videos.listFromUrl(url, function (err, videos_list) { |
79 | if (err) logger.error('Cannot remove all remote videos of %s.', url) | 81 | if (err) { |
80 | else logger.info('%s pod removed.', url) | 82 | logger.error('Cannot list videos from url.', { error: err }) |
83 | next(err) | ||
84 | } | ||
81 | 85 | ||
82 | res.type('json').status(204).end() | 86 | videos.removeRemoteVideos(videos_list, function (err) { |
87 | if (err) { | ||
88 | logger.error('Cannot remove remote videos.', { error: err }) | ||
89 | next(err) | ||
90 | } | ||
91 | |||
92 | res.type('json').status(204).end() | ||
93 | }) | ||
83 | }) | 94 | }) |
84 | }) | 95 | }) |
85 | } | 96 | } |