summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2017-11-23 20:54:50 +0300
committerValentin Popov <info@valentineus.link>2017-11-23 20:54:50 +0300
commitde3c3a655329f7c4cbd9d7612fdc66ec5266c3e7 (patch)
tree6b65f0d1fe03e2b1ccc3c921f94418d42643b0b9 /classes
parent05512c5440ff6d2bbb31e6e5d886c83e8510f15d (diff)
downloadlocal_webhooks-de3c3a655329f7c4cbd9d7612fdc66ec5266c3e7.tar.xz
local_webhooks-de3c3a655329f7c4cbd9d7612fdc66ec5266c3e7.zip
Correcting errors, adding a logging system
Diffstat (limited to 'classes')
-rw-r--r--classes/handler.php10
1 files changed, 6 insertions, 4 deletions
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