diff --git a/classes/incident.php b/classes/incident.php index 8a1fbc9..c71b74b 100644 --- a/classes/incident.php +++ b/classes/incident.php @@ -1,4 +1,6 @@ bind_param("ii", $service, $status_id); $stmt->execute(); $query = $stmt->get_result(); - - $query = $mysqli->query("SELECT * FROM services_subscriber WHERE serviceIDFK=" . $service); - while($subscriber = $query->fetch_assoc()){ - $subscriberQuery = $mysqli->query("SELECT * FROM subscribers WHERE subscriberID=" . $subscriber['subscriberIDFK']); - while($subscriberData = $subscriberQuery->fetch_assoc()){ - $telegramID = $subscriberData['telegramID']; - $firstname = $subscriberData['firstname']; - - $tg_message = urlencode('Hi ' . $firstname . chr(10) . 'There is a status update on a service that you have subscribed. View online'); - $response = json_decode(file_get_contents("https://api.telegram.org/bot" . TG_BOT_API_TOKEN . "/sendMessage?chat_id=" . $telegramID . "&parse_mode=HTML&text=" . $tg_message), true); - if($response['ok'] == true){ - $tgsent = true; - } - } - } - if($tgsent){ - header("Location: ".WEB_URL."/admin?sent=true"); + + // Perform notification to subscribers + $notify = new Notification(); + $notify->get_service_details($status_id); - } else { - header("Location: ".WEB_URL."/admin?sent=false"); - } + $notify->type = $type; + $notify->time = $time; + $notify->title = $title; + $notify->text = $text; + $notify->status = $statuses[$type]; + + $notify->notify_subscribers(); + + header("Location: ".WEB_URL."/admin?sent=true"); } } - } /** * Renders incident @@ -194,7 +191,7 @@ class Incident implements JsonSerializable global $icons; global $classes, $user; $admin = $admin && (($user->get_rank()<=1) || ($user->get_username() == $this->username)); - + $Parsedown = new Parsedown(); ?>
@@ -208,7 +205,7 @@ class Incident implements JsonSerializable
- text; ?> + setBreaksEnabled(true)->text($this->text); ?>