diff --git a/include/controllers/default/crunchbutton/api/twilio/sms.php b/include/controllers/default/crunchbutton/api/twilio/sms.php index 2c16e3f51..8995824a8 100644 --- a/include/controllers/default/crunchbutton/api/twilio/sms.php +++ b/include/controllers/default/crunchbutton/api/twilio/sms.php @@ -221,7 +221,6 @@ class Controller_api_twilio_sms extends Crunchbutton_Controller_Rest { // Log Log::debug( [ 'action' => 'saving the answer', 'id_support' => $answer->id_support, 'phone' => $phone, 'message' => $message, 'type' => 'sms' ] ); - } // c::timeout(function() use ($nums, $b, $twilio, $env, $id) { diff --git a/include/library/Crunchbutton/Hipchat/Notification.php b/include/library/Crunchbutton/Hipchat/Notification.php index ed7937dbc..a78015bd9 100644 --- a/include/library/Crunchbutton/Hipchat/Notification.php +++ b/include/library/Crunchbutton/Hipchat/Notification.php @@ -17,10 +17,24 @@ class Crunchbutton_Hipchat_Notification extends Cana_Model { self::sendNotification($msg); } + public static function NewSupport($support) { + $msg = "A new customer service issue (#$support->id_support): ". + "$support->name, $support->phone, $support->message"; + self::sendNotification($msg); + } + + public static function NewSupportAnswer($answer) { + $msg = "$answer->name has responded to ". + "customer service issue #$answer->id_support."; + self::sendNotification($msg); + } + public static function sendNotification($msg) { + error_log($msg); $msg = urlencode(str_replace('\n', ' ', $msg)); $env = c::env() == 'live' ? 'live' : 'dev'; - $msg = "[env:$env] " . $msg; + $msg = "[env:$env]+" . $msg; + error_log($msg); $url = self::$api_url. '?auth_token='.self::$auth_token. '&room_id='.self::$room_id. @@ -29,6 +43,7 @@ class Crunchbutton_Hipchat_Notification extends Cana_Model { '¬ify=0'. // don't blink the chat window '&format=json'. '&message='.$msg; + error_log($url); $req = \Httpful\Request::get($url); $req->expects('json'); $rsp = $req->sendIt(); @@ -37,7 +52,7 @@ class Crunchbutton_Hipchat_Notification extends Cana_Model { public static function sendUrgentNotification($msg) { $msg = urlencode(str_replace('\n', ' ', $msg)); - $msg = '[env:'.c::env().'] ' . $msg; + $msg = '[env:'.c::env().']+' . $msg; $url = self::$api_url. '?auth_token='.self::$auth_token. '&room_id='.self::$room_id. diff --git a/include/library/Crunchbutton/Support.php b/include/library/Crunchbutton/Support.php index 5e08d863b..9d5d304c0 100644 --- a/include/library/Crunchbutton/Support.php +++ b/include/library/Crunchbutton/Support.php @@ -144,5 +144,6 @@ class Crunchbutton_Support extends Cana_Table { public function save() { parent::save(); + Crunchbutton_Hipchat_Notification::NewSupport($this); } -} \ No newline at end of file +} diff --git a/include/library/Crunchbutton/Support/Answer.php b/include/library/Crunchbutton/Support/Answer.php index 7fbc80a37..0b7cf6988 100644 --- a/include/library/Crunchbutton/Support/Answer.php +++ b/include/library/Crunchbutton/Support/Answer.php @@ -20,5 +20,6 @@ class Crunchbutton_Support_Answer extends Cana_Table { public function save() { parent::save(); + Crunchbutton_Hipchat_Notification::NewSupportAnswer($this); } -} \ No newline at end of file +}