소스 검색

[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();