From b4d0f8b409b33622e973c960ac3403ba5cc213ed Mon Sep 17 00:00:00 2001
From: David Upton There was an issue with a user subscribing to Everbridge Emergency Alerts from boston.gov. The subscription came from a form on: " . \Drupal::request()->server->get("HTTP_REFERER") . " The user was located at: " . \Drupal::request()->getClientIp() . " The information completed on the form was:
- " . print_r($params["message"], TRUE) . "
-
There was an issue with a user subscribing to Everbridge Emergency Alerts from boston.gov.
"; + $message['body'][] = "The subscription came from a form on: " . \Drupal::request()->server->get("HTTP_REFERER") . "
"; + $message['body'][] = "The user was located at: " . \Drupal::request()->getClientIp() ?? "--" . "
"; + $message['body'][] = "The error reported was: " . $params["message"]["error"] ?? "--" . "
"; + $message['body'][] = "The information completed on the form was:
";
+ $message['body'][] = "
" . print_r($params["message"]["form"] ?? [], TRUE) . ""; + $message['body'][] = ""; } } diff --git a/docroot/modules/custom/bos_components/modules/bos_emergency_alerts/src/Controller/ApiRouter.php b/docroot/modules/custom/bos_components/modules/bos_emergency_alerts/src/Controller/ApiRouter.php index 3ca2f4de42..e309987c75 100644 --- a/docroot/modules/custom/bos_components/modules/bos_emergency_alerts/src/Controller/ApiRouter.php +++ b/docroot/modules/custom/bos_components/modules/bos_emergency_alerts/src/Controller/ApiRouter.php @@ -163,17 +163,17 @@ private function isFlooding(Request $request) { * * Actual email formatted in bos_emergency_alerts_mail(). */ - public function mailAlert(): void { + public function mailAlert($message): void { $request = $this->request->request->all(); - if (empty($this->settings["email_alerts"])) { + if (empty($this->settings["emergency_alerts_settings"]["email_alerts"])) { $this->log->warning("Emergency_alerts email recipient is not set. An error has been encountered, but no email has been sent."); return; } - $params['message'] = $request; - $result = $this->mail->mail("bos_emergency_alerts", "subscribe_error", $this->settings["email_alerts"], "en", $params, NULL, TRUE); + $params['message'] = ["error" => $message, "form" => $request]; + $result = $this->mail->mail("bos_emergency_alerts", "subscribe_error", $this->settings["emergency_alerts_settings"]["email_alerts"], "en", $params, NULL, TRUE); if ($result['result'] !== TRUE) { $this->log->warning("There was a problem sending your message and it was not sent."); } @@ -220,14 +220,14 @@ public function responseOutput(string $message, int $type): Response { $json['errors'] = ["message" => $message]; unset($json['contact']); $response->setContent(json_encode($json)); - $this->log->error("Internal Error"); - $this->mailAlert(); + $this->mailAlert($message); break; default: $json['status'] = 'error'; $json['errors'] = ["message" => $message]; $response->setContent(json_encode($json)); + $this->mailAlert($message); break; } return $response; diff --git a/docroot/modules/custom/bos_components/modules/bos_emergency_alerts/src/Controller/EmergencyAlertsSubscriberBase.php b/docroot/modules/custom/bos_components/modules/bos_emergency_alerts/src/Controller/EmergencyAlertsSubscriberBase.php index 1c4e0559c3..76c9e1f297 100644 --- a/docroot/modules/custom/bos_components/modules/bos_emergency_alerts/src/Controller/EmergencyAlertsSubscriberBase.php +++ b/docroot/modules/custom/bos_components/modules/bos_emergency_alerts/src/Controller/EmergencyAlertsSubscriberBase.php @@ -74,18 +74,6 @@ protected function executeCurl(bool $retry = FALSE): array { return $this->curl->executeCurl($retry); } catch (Exception $e) { - $config = CobSettings::getSettings("EA_SETTINGS", "bos_emergency_alerts"); - $mailManager = \Drupal::service('plugin.manager.mail'); - if (!$mailManager->mail( - "bos_emergency_alerts", - 'subscribe_error', - $config["emergency_alerts_settings"]["email_alerts"] ?? "digital-dev@boston.gov", - "en", - ["message" => (array) $this->curl->request()], - NULL, - TRUE)) { - \Drupal::logger("bos_emergency_alerts")->warning(t("Error Email sending from Drupal has failed.")); - } throw new Exception($e->getMessage(), $e->getCode()); } } diff --git a/docroot/modules/custom/bos_components/modules/bos_geocoder/src/Controller/BosGeocoder.php b/docroot/modules/custom/bos_components/modules/bos_geocoder/src/Controller/BosGeocoder.php index 45a08b62c8..9d9788964f 100644 --- a/docroot/modules/custom/bos_components/modules/bos_geocoder/src/Controller/BosGeocoder.php +++ b/docroot/modules/custom/bos_components/modules/bos_geocoder/src/Controller/BosGeocoder.php @@ -182,7 +182,7 @@ private function lookupArcGISGeocoder(string $direction): BosGeoAddress|bool { $config = $this->config["arcgis"]; - $curl = new BosCurlControllerBase([], TRUE); + $curl = new BosCurlControllerBase([], FALSE); $base = $config["base_url"]; switch ($direction) { @@ -295,7 +295,7 @@ private function lookupGoogleGeocoder(string $direction): BosGeoAddress|bool { $config = $this->config["google"]; - $curl = new BosCurlControllerBase([], TRUE); + $curl = new BosCurlControllerBase([], FALSE); $base = $config["base_url"]; $token = $config["token"]; //"AIzaSyBIJymUhZLfQNNds5zZ6JsEz-tgLfN8qD4"; diff --git a/docroot/modules/custom/bos_core/src/Controllers/Curl/BosCurlControllerBase.php b/docroot/modules/custom/bos_core/src/Controllers/Curl/BosCurlControllerBase.php index 62b15a321a..a8d180a373 100644 --- a/docroot/modules/custom/bos_core/src/Controllers/Curl/BosCurlControllerBase.php +++ b/docroot/modules/custom/bos_core/src/Controllers/Curl/BosCurlControllerBase.php @@ -278,7 +278,7 @@ public function executeCurl(bool $retry = FALSE): array { elseif ($this->response["http_code"] >= 300 || $this->response["http_code"] < 200) { // Got an error or non-200 code - throw error - $this->error = "Unexpected Endpoint Error (HTTP Code: {$this->response["http_code"]}): {$this->response["response_raw"]}"; + $this->error = "Endpoint Error (HTTP Code: {$this->response["http_code"]}): {$this->response["response_raw"]}"; $this->writeError($this->error); throw new Exception($this->error, self::BAD_REQUEST); } @@ -363,6 +363,7 @@ private function extractHeaders(string &$response, array &$headers): void { // Log \Drupal::logger("BosCurlHandler")->info(" + Headers have been extracted.
Endpoint | {$this->request["host"]} |
Response Headers | {$_headers} |
Issue | {$narrative} |
Endpoint | " . $this->request["host"] ?? "unknown" . " |
JSON Payload | " . json_encode($this->request["body"] ?? []) . " |
Endpoint | " . ($this->request["host"] ?? "unknown") . " |
JSON Payload | " . (json_encode($this->request["body"]) ?? []) . " |
JSON Response | " . print_r($this->response["response_raw"]??"", TRUE) . " |