This commit is contained in:
Daniel Camargo 2013-04-16 09:26:56 -03:00
parent b2086b3bd9
commit 5ab7788f9c
3 changed files with 13 additions and 16 deletions

View File

@ -87,10 +87,10 @@
</phone>
<text>
<Daniel>***REMOVED***</Daniel>
<Devin>_PHONE_</Devin>
<!--<Devin>_PHONE_</Devin>
<Judd>_PHONE_</Judd>
<David>_PHONE_</David>
<Nick>_PHONE_</Nick>
<Nick>_PHONE_</Nick>-->
</text>
<stripe>
<dev>

View File

@ -9,12 +9,20 @@ class Controller_api_Support extends Crunchbutton_Controller_Rest {
if (c::getPagePiece(2) == 'sms') {
// Create a twilio session
$tsess = new Session_Twilio;
$tsess->phone = $this->request()['phone'];
$tsess->data = json_encode( $_REQUEST );
$tsess->save();
$support = new Crunchbutton_Support;
$support->type = 'sms';
$support->name = $this->request()['name'];
$support->phone = $this->request()['phone'];
$support->message = $this->request()['message'];
$support->ip = $_SERVER['REMOTE_ADDR'];
$support->id_session_twilio = $tsess->id_session_twilio;
$support->date = date('Y-m-d H:i:s');
if( c::user()->id_user ){
$support->id_user = c::user()->id_user;

View File

@ -38,18 +38,7 @@ class Crunchbutton_Support extends Cana_Table {
// Log
Log::debug( [ 'action' => 'support', 'message' => $message, 'type' => 'support' ] );
$data = [ 'request' => $_REQUEST, 'support' => json_decode( $this->json() ) ];
// Create a twilio session
$tsess = new Session_Twilio;
$tsess->phone = $this->phone;
$tsess->data = json_encode( $data );
$tsess->save();
$this->id_session_twilio = $tsess->id_session_twilio;
$this->save();
$message = '@'.$tsess->id_session_twilio.' : ' . $message;
$message = '@'.$this->id_session_twilio.' : ' . $message;
$message = str_split( $message, 160 );
// Send this message to the customer service
@ -58,7 +47,7 @@ class Crunchbutton_Support extends Cana_Table {
foreach ($message as $msg) {
try {
// Log
Log::debug( [ 'action' => 'sending sms - support', 'session id' => $tsess->id_session_twilio, 'num' => $num, 'msg' => $msg, 'type' => 'support' ] );
Log::debug( [ 'action' => 'sending sms - support', 'session id' => $this->id_session_twilio, 'num' => $num, 'msg' => $msg, 'type' => 'support' ] );
$twilio->account->sms_messages->create(
c::config()->twilio->{$env}->outgoingTextCustomer,
'+1'.$num,
@ -66,7 +55,7 @@ class Crunchbutton_Support extends Cana_Table {
);
} catch (Exception $e) {
// Log
Log::debug( [ 'action' => 'ERROR sending sms - support', 'session id' => $tsess->id_session_twilio, 'num' => $num, 'msg' => $msg, 'type' => 'sms' ] );
Log::debug( [ 'action' => 'ERROR sending sms - support', 'session id' => $this->id_session_twilio, 'num' => $num, 'msg' => $msg, 'type' => 'sms' ] );
}
}
}