This commit is contained in:
BDC 2013-04-18 23:27:37 -04:00
parent 3c4057e65a
commit f53602294f
4 changed files with 21 additions and 5 deletions

View File

@ -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) {

View File

@ -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 {
'&notify=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.

View File

@ -144,5 +144,6 @@ class Crunchbutton_Support extends Cana_Table {
public function save() {
parent::save();
Crunchbutton_Hipchat_Notification::NewSupport($this);
}
}
}

View File

@ -20,5 +20,6 @@ class Crunchbutton_Support_Answer extends Cana_Table {
public function save() {
parent::save();
Crunchbutton_Hipchat_Notification::NewSupportAnswer($this);
}
}
}