summaryrefslogtreecommitdiff
path: root/classes/events.php
diff options
context:
space:
mode:
authorValentin Popov <info@valentineus.link>2017-10-26 06:35:52 +0300
committerGitHub <noreply@github.com>2017-10-26 06:35:52 +0300
commit9ecf83b1d66aed22b12f7de2fd9bdbf0015226b6 (patch)
tree4f04b51fde3990f3d633b7b8b5f34339f6c84b37 /classes/events.php
parent430c9fa09a4fc1995b8b7751f7b41aeec18298b4 (diff)
parent54d1d030ec3e604cb2dd63819664d05677befe16 (diff)
downloadlocal_webhooks-9ecf83b1d66aed22b12f7de2fd9bdbf0015226b6.tar.xz
local_webhooks-9ecf83b1d66aed22b12f7de2fd9bdbf0015226b6.zip
Merge pull request #2 from valentineus/list-events
List events
Diffstat (limited to 'classes/events.php')
-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..33e278b 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::handler_callback($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 handler_callback($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