Reworked the event handler
Signed-off-by: Valentin Popov <info@valentineus.link>
This commit is contained in:
		@@ -26,7 +26,6 @@ namespace local_webhooks;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
defined("MOODLE_INTERNAL") || die();
 | 
					defined("MOODLE_INTERNAL") || die();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require_once(__DIR__ . "/../locallib.php");
 | 
					 | 
				
			||||||
require_once(__DIR__ . "/../lib.php");
 | 
					require_once(__DIR__ . "/../lib.php");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -42,15 +41,15 @@ class handler {
 | 
				
			|||||||
     * @param object $event
 | 
					     * @param object $event
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static function events($event) {
 | 
					    public static function events($event) {
 | 
				
			||||||
 | 
					        /* Gets the information about the event */
 | 
				
			||||||
        $data = $event->get_data();
 | 
					        $data = $event->get_data();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!is_array($recordlist = local_webhooks_cache_get($data["eventname"]))) {
 | 
					        /* Gets a list of involved services */
 | 
				
			||||||
            $recordlist = local_webhooks_search_services_by_event($data["eventname"], true);
 | 
					        if (!empty($records = local_webhooks_get_list_records_by_event($data["eventname"]))) {
 | 
				
			||||||
            local_webhooks_cache_set($data["eventname"], $recordlist);
 | 
					            foreach ($records as $record) {
 | 
				
			||||||
        }
 | 
					                /* Sends an alert */
 | 
				
			||||||
 | 
					 | 
				
			||||||
        foreach ($recordlist as $record) {
 | 
					 | 
				
			||||||
                local_webhooks_send_request($data, $record);
 | 
					                local_webhooks_send_request($data, $record);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user