diff options
author | Valentin Popov <info@valentineus.link> | 2018-03-21 07:13:13 +0300 |
---|---|---|
committer | Valentin Popov <info@valentineus.link> | 2018-03-21 07:13:13 +0300 |
commit | 9ee0af7e28b82dfdfc5c4b6f338885e44aabbc17 (patch) | |
tree | d8d17c636606cad833ba896a5774cd9cf5228329 /classes/handler.php | |
parent | 9006e6b9ddd849e7886256723a945ce050db89e6 (diff) | |
download | local_webhooks-9ee0af7e28b82dfdfc5c4b6f338885e44aabbc17.tar.xz local_webhooks-9ee0af7e28b82dfdfc5c4b6f338885e44aabbc17.zip |
Reworked the event handler
Signed-off-by: Valentin Popov <info@valentineus.link>
Diffstat (limited to 'classes/handler.php')
-rw-r--r-- | classes/handler.php | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/classes/handler.php b/classes/handler.php index c2c737f..3bc69cf 100644 --- a/classes/handler.php +++ b/classes/handler.php @@ -26,7 +26,6 @@ namespace local_webhooks; defined("MOODLE_INTERNAL") || die(); -require_once(__DIR__ . "/../locallib.php"); require_once(__DIR__ . "/../lib.php"); /** @@ -42,15 +41,15 @@ class handler { * @param object $event */ public static function events($event) { + /* Gets the information about the event */ $data = $event->get_data(); - if (!is_array($recordlist = local_webhooks_cache_get($data["eventname"]))) { - $recordlist = local_webhooks_search_services_by_event($data["eventname"], true); - local_webhooks_cache_set($data["eventname"], $recordlist); - } - - foreach ($recordlist as $record) { - local_webhooks_send_request($data, $record); + /* Gets a list of involved services */ + if (!empty($records = local_webhooks_get_list_records_by_event($data["eventname"]))) { + foreach ($records as $record) { + /* Sends an alert */ + local_webhooks_send_request($data, $record); + } } } }
\ No newline at end of file |