فهرست منبع

[bugfix][Fix #42] possibility to send a command without args

B Thibault 8 سال پیش
والد
کامیت
38f8a59050
1فایلهای تغییر یافته به همراه5 افزوده شده و 3 حذف شده
  1. 5 3
      srv/src/httpServ.js

+ 5 - 3
srv/src/httpServ.js

@@ -156,8 +156,7 @@ Server.prototype.onRequest = function(req, res) {
             }
         } else if (req.urlObj.match(["api", "cmd"])) {
             if (!req.urlObj.queryTokens.room ||
-                !req.urlObj.queryTokens.cmd ||
-                !req.urlObj.queryTokens.args) {
+                !req.urlObj.queryTokens.cmd) {
                 res.writeHeader("400", "Bad request");
                 res.end();
             } else {
@@ -169,7 +168,10 @@ Server.prototype.onRequest = function(req, res) {
                 } else if (!cmd) {
                     res.writeHeader("404", "No such command");
                 } else {
-                    res.slack.sendCommand(chan, cmd, req.urlObj.queryTokens.args[0]);
+                    var args = req.urlObj.queryTokens.args ? req.urlObj.queryTokens.args[0] : "";
+                    if (args === true)
+                        args = "";
+                    res.slack.sendCommand(chan, cmd, args);
                     res.writeHeader("204", "No Content");
                 }
                 res.end();