From de3c3a655329f7c4cbd9d7612fdc66ec5266c3e7 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 23 Nov 2017 21:54:50 +0400 Subject: Correcting errors, adding a logging system --- classes/handler.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'classes') diff --git a/classes/handler.php b/classes/handler.php index cb32112..8de9b3c 100644 --- a/classes/handler.php +++ b/classes/handler.php @@ -27,6 +27,7 @@ namespace local_webhooks; defined("MOODLE_INTERNAL") || die(); require_once(__DIR__ . "/../lib.php"); +require_once(__DIR__ . "/../locallib.php"); require_once($CFG->libdir . "/filelib.php"); @@ -55,17 +56,17 @@ class handler { /** * Processes each callback. * - * @param array $data + * @param array $data * @param object $callback */ private static function handler_callback($data, $callback) { global $CFG; if (boolval($callback->enable)) { - if (!empty($data["eventname"])) { + if (!empty($callback->events[$data["eventname"]])) { $urlparse = parse_url($CFG->wwwroot); - $data["host"] = $urlparse['host']; + $data["host"] = $urlparse['host']; $data["token"] = $callback->token; $data["extra"] = $callback->other; @@ -77,7 +78,7 @@ class handler { /** * Sending data to the node. * - * @param array $data + * @param array $data * @param object $callback */ private static function send($data, $callback) { @@ -86,6 +87,7 @@ class handler { $curl->post($callback->url, json_encode($data)); $response = $curl->getResponse(); + \local_webhooks_events::response_answer($callback->id, $response); return $response; } } \ No newline at end of file -- cgit v1.2.3