PeerTube/routes/api/remoteVideos.js

30 lines
782 B
JavaScript
Raw Normal View History

2015-06-09 17:41:40 +02:00
;(function () {
'use strict'
var express = require('express')
var router = express.Router()
var middleware = require('../../middlewares')
var videos = require('../../src/videos')
function addRemoteVideos (req, res, next) {
videos.addRemote(req.body.data, function (err, video) {
2015-10-30 17:51:40 +01:00
if (err) return next(err)
2015-06-09 17:41:40 +02:00
res.json(video)
})
}
function removeRemoteVideo (req, res, next) {
videos.removeRemote(req.body.signature.url, req.body.data.magnetUri, function (err) {
2015-10-30 17:51:40 +01:00
if (err) return next(err)
2015-06-09 17:41:40 +02:00
res.status(204)
})
}
router.post('/add', middleware.cache(false), middleware.decryptBody, addRemoteVideos)
router.post('/remove', middleware.cache(false), middleware.decryptBody, removeRemoteVideo)
module.exports = router
})()