summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2017-10-26 05:45:53 +0300
committerValentin Popov <info@valentineus.link>2017-10-26 05:45:53 +0300
commit8651e6a1571fd99c4adedf3a0310e8a4fca957e3 (patch)
treec741cd4faa1a2b81df1eac37952f845d64afd75d
parent28632834afba8385fe4082add80bb7438f17a7a0 (diff)
downloadlocal_webhooks-8651e6a1571fd99c4adedf3a0310e8a4fca957e3.tar.xz
local_webhooks-8651e6a1571fd99c4adedf3a0310e8a4fca957e3.zip
The event handler for sending
-rw-r--r--classes/events.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/classes/events.php b/classes/events.php
index 5dfb0cf..5b93a9c 100644
--- a/classes/events.php
+++ b/classes/events.php
@@ -59,7 +59,7 @@ class events {
if ($callbacks->valid()) {
foreach ($callbacks as $callback) {
- self::send($data, $callback);
+ self::handlerCallback($data, $callback);
}
}
@@ -67,20 +67,34 @@ class events {
}
/**
- * Sending data to the node.
+ * Processes each callback.
*
* @param array $data
* @param object $callback
*/
- private static function send($data, $callback) {
+ private static function handlerCallback($data, $callback) {
if ($callback->enable) {
- $curl = new curl();
- $package = self::packup($data);
- $curl::request($callback->url, $package);
+ $events = unserialize(gzuncompress(base64_decode($callback->events)));
+
+ if (boolval($events[$data["eventname"]])) {
+ self::send($data, $callback);
+ }
}
}
/**
+ * Sending data to the node.
+ *
+ * @param array $data
+ * @param object $callback
+ */
+ private static function send($data, $callback) {
+ $curl = new curl();
+ $package = self::packup($data);
+ $curl::request($callback->url, $package);
+ }
+
+ /**
* Packs the data for transmission.
*
* @param array $data