|
@@ -2,7 +2,6 @@ var serverSettings = require("../settings/"),
|
2
|
2
|
spawn = require("child_process").spawn,
|
3
|
3
|
path = require("path"),
|
4
|
4
|
_ = require("underscore"),
|
5
|
|
- Audiogram = require("../audiogram/"),
|
6
|
5
|
logger = require("../lib/logger"),
|
7
|
6
|
transports = require("../lib/transports");
|
8
|
7
|
|
|
@@ -22,8 +21,6 @@ function validate(req, res, next) {
|
22
|
21
|
return res.status(500).send("No valid audio received.");
|
23
|
22
|
}
|
24
|
23
|
|
25
|
|
- req.body.settings.id = req.file.destination.split(path.sep).pop();
|
26
|
|
-
|
27
|
24
|
// Start at the beginning, or specified time
|
28
|
25
|
if (req.body.settings.start) {
|
29
|
26
|
req.body.settings.start = +req.body.settings.start;
|
|
@@ -39,18 +36,22 @@ function validate(req, res, next) {
|
39
|
36
|
|
40
|
37
|
function route(req, res) {
|
41
|
38
|
|
42
|
|
- var audiogram = new Audiogram(req.body.settings);
|
|
39
|
+ var id = req.file.destination.split(path.sep).pop();
|
43
|
40
|
|
44
|
|
- transports.uploadAudio(audiogram.audioPath, "audio/" + audiogram.id,function(err) {
|
|
41
|
+ transports.uploadAudio(path.join(req.file.destination, "audio"), "audio/" + id,function(err) {
|
45
|
42
|
|
46
|
43
|
if (err) {
|
47
|
44
|
throw err;
|
48
|
45
|
}
|
49
|
46
|
|
50
|
47
|
// Queue up the job with a timestamp
|
51
|
|
- transports.addJob(_.extend({ created: (new Date()).getTime() }, req.body.settings));
|
|
48
|
+ transports.addJob({
|
|
49
|
+ created: (new Date()).getTime(),
|
|
50
|
+ settings: req.body.settings,
|
|
51
|
+ caption: req.body.caption
|
|
52
|
+ });
|
52
|
53
|
|
53
|
|
- res.json({ id: req.body.settings.id });
|
|
54
|
+ res.json({ id: id });
|
54
|
55
|
|
55
|
56
|
// If there's no separate worker, spawn one right away
|
56
|
57
|
if (!serverSettings.worker) {
|