fix response if no action is to be taken
authorMichael Wallner <mike@php.net>
Wed, 9 Mar 2016 15:45:13 +0000 (16:45 +0100)
committerMichael Wallner <mike@php.net>
Wed, 9 Mar 2016 15:45:13 +0000 (16:45 +0100)
app/Controller/Github/Hook/Receive.php

index 9bc1323e1a1d4ce08ab65ea3edc86266835982e6..1094fd25e45491c894d07ae3f15389a228fb3079 100644 (file)
@@ -51,12 +51,14 @@ class Receive implements Controller
                        case "create":
                        case "release":
                                if (($json = json_decode($request->getBody()))) {
-                                       $this->$evt($json)->done(function($result) use($response) {
-                                               list($created) = $result;
-                                               $response->setResponseCode(201);
-                                               $response->setHeader("Location", $created->url);
-                                       });
-                                       $this->github->drain();
+                                       if (($queue = $this->$evt($json))) {
+                                               $queue->done(function($result) use($response) {
+                                                       list($created) = $result;
+                                                       $response->setResponseCode(201);
+                                                       $response->setHeader("Location", $created->url);
+                                               });
+                                               $this->github->drain();
+                                       }
                                } else {
                                        $response->setResponseCode(415);
                                        $response->setContentType($request->getHeader("Content-Type"));