partial #951 - testing new server variable

This commit is contained in:
Daniel Camargo 2013-04-03 14:51:48 -03:00
parent c4d5a751bc
commit b6f9b74d49
7 changed files with 22 additions and 20 deletions

View File

@ -159,7 +159,7 @@
<outgoingCustomer>+18003514161</outgoingCustomer> <outgoingCustomer>+18003514161</outgoingCustomer>
<outgoingRestaurant>+18003514161</outgoingRestaurant> <outgoingRestaurant>+18003514161</outgoingRestaurant>
</olddev> </olddev>
<testnumber>_PHONE_</testnumber> <testnumber>***REMOVED***</testnumber>
<voice>male</voice> <voice>male</voice>
<greeting>Hello. This is crunchbutton, </greeting> <greeting>Hello. This is crunchbutton, </greeting>
<maxcallback>5</maxcallback> <maxcallback>5</maxcallback>

View File

@ -44,7 +44,7 @@ class Controller_api_order extends Crunchbutton_Controller_Rest {
Log::debug([ Log::debug([
'order' => $order->id_order, 'order' => $order->id_order,
'action' => '/sayorder (accepted)', 'action' => '/sayorder (accepted)',
'host' => $_SERVER['__HTTP_HOST'], 'host' => $_SERVER['__HTTP_HOST_CALLBACK'],
'type' => 'notification' 'type' => 'notification'
]); ]);
@ -95,7 +95,7 @@ class Controller_api_order extends Crunchbutton_Controller_Rest {
Log::debug([ Log::debug([
'order' => $order->id_order, 'order' => $order->id_order,
'action' => '/sayorderonly: 2: CONFIRMED', 'action' => '/sayorderonly: 2: CONFIRMED',
'host' => $_SERVER['__HTTP_HOST'], 'host' => $_SERVER['__HTTP_HOST_CALLBACK'],
'type' => 'notification' 'type' => 'notification'
]); ]);
echo '<Gather action="/api/order/'.$order->id_order.'/sayorderonly?id_notification='.$_REQUEST['id_notification'].'" numDigits="1" timeout="10" finishOnKey="#" method="get">'; echo '<Gather action="/api/order/'.$order->id_order.'/sayorderonly?id_notification='.$_REQUEST['id_notification'].'" numDigits="1" timeout="10" finishOnKey="#" method="get">';
@ -139,7 +139,7 @@ class Controller_api_order extends Crunchbutton_Controller_Rest {
Log::debug([ Log::debug([
'order' => $order->id_order, 'order' => $order->id_order,
'action' => '/doconfirm: 1: CONFIRMED', 'action' => '/doconfirm: 1: CONFIRMED',
'host' => $_SERVER['__HTTP_HOST'], 'host' => $_SERVER['__HTTP_HOST_CALLBACK'],
'type' => 'notification' 'type' => 'notification'
]); ]);
echo '<Gather action="/api/order/'.$order->id_order.'/sayorderonly?id_notification='.$_REQUEST['id_notification'].'" numDigits="1" timeout="10" finishOnKey="#" method="get">'; echo '<Gather action="/api/order/'.$order->id_order.'/sayorderonly?id_notification='.$_REQUEST['id_notification'].'" numDigits="1" timeout="10" finishOnKey="#" method="get">';
@ -158,7 +158,7 @@ class Controller_api_order extends Crunchbutton_Controller_Rest {
Log::debug([ Log::debug([
'order' => $order->id_order, 'order' => $order->id_order,
'action' => 'RESEND', 'action' => 'RESEND',
'host' => $_SERVER['__HTTP_HOST'], 'host' => $_SERVER['__HTTP_HOST_CALLBACK'],
'type' => 'notification' 'type' => 'notification'
]); ]);

View File

@ -41,6 +41,8 @@ class Crunchbutton_App extends Cana_App {
break; break;
} }
$_SERVER['__HTTP_HOST_CALLBACK'] = $_SERVER['__HTTP_HOST'];
switch ($_SERVER['__HTTP_HOST']) { switch ($_SERVER['__HTTP_HOST']) {
case 'crunchbutton.localhost': case 'crunchbutton.localhost':
case 'wenzel.localhost': case 'wenzel.localhost':

View File

@ -82,7 +82,7 @@ class Crunchbutton_Notification extends Cana_Table
'order' => $order->id_order, 'order' => $order->id_order,
'action' => 'send order call', 'action' => 'send order call',
'num' => $num, 'num' => $num,
'host' => $_SERVER['__HTTP_HOST'], 'host' => $_SERVER['__HTTP_HOST_CALLBACK'],
'callback' => $callback, 'callback' => $callback,
'type' => 'notification' 'type' => 'notification'
]); ]);
@ -98,9 +98,9 @@ class Crunchbutton_Notification extends Cana_Table
$call = $twilio->account->calls->create( $call = $twilio->account->calls->create(
c::config()->twilio->{$env}->outgoingRestaurant, c::config()->twilio->{$env}->outgoingRestaurant,
'+1'.$num, '+1'.$num,
'http://'.$_SERVER['__HTTP_HOST'].'/api/order/'.$order->id_order.'/say?id_notification='.$this->id_notification, 'http://'.$_SERVER['__HTTP_HOST_CALLBACK'].'/api/order/'.$order->id_order.'/say?id_notification='.$this->id_notification,
[ [
'StatusCallback' => 'http://'.$_SERVER['__HTTP_HOST'].'/api/notification/'.$log->id_notification_log.'/callback' 'StatusCallback' => 'http://'.$_SERVER['__HTTP_HOST_CALLBACK'].'/api/notification/'.$log->id_notification_log.'/callback'
// 'IfMachine' => 'Hangup' // 'IfMachine' => 'Hangup'
] ]
); );

View File

@ -34,7 +34,7 @@ class Crunchbutton_Notification_Log extends Cana_Table {
'customer_phone' => $this->order()->phone, 'customer_phone' => $this->order()->phone,
'customer_name' => $this->order()->name, 'customer_name' => $this->order()->name,
'action' => '#'.$this->id_order.' MAX CB for '.$this->order()->restaurant()->name."\nR# ".$this->order()->restaurant()->phone()."\n C# ".$this->order()->phone(), 'action' => '#'.$this->id_order.' MAX CB for '.$this->order()->restaurant()->name."\nR# ".$this->order()->restaurant()->phone()."\n C# ".$this->order()->phone(),
'host' => $_SERVER['__HTTP_HOST'], 'host' => $_SERVER['__HTTP_HOST_CALLBACK'],
'type' => 'notification' 'type' => 'notification'
]); ]);
@ -74,7 +74,7 @@ class Crunchbutton_Notification_Log extends Cana_Table {
'customer_phone' => $this->order()->phone, 'customer_phone' => $this->order()->phone,
'customer_name' => $this->order()->name, 'customer_name' => $this->order()->name,
'action' => '#'.$this->id_order.' MAX CONFIRM CB for '.$this->order()->restaurant()->name."\nR# ".$this->order()->restaurant()->phone()."\nC# ".$this->order()->phone(), 'action' => '#'.$this->id_order.' MAX CONFIRM CB for '.$this->order()->restaurant()->name."\nR# ".$this->order()->restaurant()->phone()."\nC# ".$this->order()->phone(),
'host' => $_SERVER['__HTTP_HOST'], 'host' => $_SERVER['__HTTP_HOST_CALLBACK'],
'type' => 'notification' 'type' => 'notification'
]); ]);
} else { } else {

View File

@ -508,7 +508,7 @@ class Crunchbutton_Order extends Cana_Table {
'order' => $this->id_order, 'order' => $this->id_order,
'confirmed' =>$this->confirmed, 'confirmed' =>$this->confirmed,
'action' => 'check confirmed', 'action' => 'check confirmed',
'host' => $_SERVER['__HTTP_HOST'], 'host' => $_SERVER['__HTTP_HOST_CALLBACK'],
'type' => 'notification' 'type' => 'notification'
]); ]);
@ -518,7 +518,7 @@ class Crunchbutton_Order extends Cana_Table {
'order' => $this->id_order, 'order' => $this->id_order,
'count' => $nl->count(), 'count' => $nl->count(),
'action' => 'confirmation call already in process', 'action' => 'confirmation call already in process',
'host' => $_SERVER['__HTTP_HOST'], 'host' => $_SERVER['__HTTP_HOST_CALLBACK'],
'type' => 'notification' 'type' => 'notification'
]); ]);
return; return;
@ -527,7 +527,7 @@ class Crunchbutton_Order extends Cana_Table {
'order' => $this->id_order, 'order' => $this->id_order,
'count' => $nl->count(), 'count' => $nl->count(),
'action' => 'starting new confirmation call', 'action' => 'starting new confirmation call',
'host' => $_SERVER['__HTTP_HOST'], 'host' => $_SERVER['__HTTP_HOST_CALLBACK'],
'type' => 'notification' 'type' => 'notification'
]); ]);
} }
@ -544,16 +544,16 @@ class Crunchbutton_Order extends Cana_Table {
/* /*
$num = '_PHONE_'; $num = '_PHONE_';
$_SERVER['____HTTP_HOST'] = 'dev.crunchr.co'; $_SERVER['____HTTP_HOST_CALLBACK'] = 'dev.crunchr.co';
*/ */
$callback = 'http://'.$_SERVER['__HTTP_HOST'].'/api/notification/'.$log->id_notification_log.'/confirm'; $callback = 'http://'.$_SERVER['__HTTP_HOST_CALLBACK'].'/api/notification/'.$log->id_notification_log.'/confirm';
Log::debug([ Log::debug([
'order' => $this->id_order, 'order' => $this->id_order,
'action' => 'dial confirm call', 'action' => 'dial confirm call',
'num' => $num, 'num' => $num,
'host' => $_SERVER['__HTTP_HOST'], 'host' => $_SERVER['__HTTP_HOST_CALLBACK'],
'callback' => $callback, 'callback' => $callback,
'type' => 'notification' 'type' => 'notification'
]); ]);
@ -562,7 +562,7 @@ class Crunchbutton_Order extends Cana_Table {
$call = $twilio->account->calls->create( $call = $twilio->account->calls->create(
c::config()->twilio->{$env}->outgoingRestaurant, c::config()->twilio->{$env}->outgoingRestaurant,
'+1'.$num, '+1'.$num,
'http://'.$_SERVER['__HTTP_HOST'].'/api/order/'.$this->id_order.'/doconfirm', 'http://'.$_SERVER['__HTTP_HOST_CALLBACK'].'/api/order/'.$this->id_order.'/doconfirm',
[ [
'StatusCallback' => $callback 'StatusCallback' => $callback
// 'IfMachine' => 'Hangup' // 'IfMachine' => 'Hangup'
@ -613,10 +613,10 @@ class Crunchbutton_Order extends Cana_Table {
public function que() { public function que() {
$order = $this; $order = $this;
Cana::timeout(function() use($order) { //Cana::timeout(function() use($order) {
/* @var $order Crunchbutton_Order */ /* @var $order Crunchbutton_Order */
$order->notify(); $order->notify();
}); // });
if (!$this->restaurant()->confirmation) { if (!$this->restaurant()->confirmation) {
c::timeout(function() use($order) { c::timeout(function() use($order) {

View File

@ -8,7 +8,7 @@ class Crunchbutton_Phaxio {
.'-F "to='.$params['to'].'" ' .'-F "to='.$params['to'].'" '
.'-F "filename=@'.$params['file'].'" '; .'-F "filename=@'.$params['file'].'" ';
if ($params['id_notification_log']) { if ($params['id_notification_log']) {
$cmd .= '-F "callback_url=http://'.$_SERVER['__HTTP_HOST'].'/api/notification/'.$params['id_notification_log'].'/callback" '; $cmd .= '-F "callback_url=http://'.$_SERVER['__HTTP_HOST_CALLBACK'].'/api/notification/'.$params['id_notification_log'].'/callback" ';
} }
$cmd .= '-F "api_key='.c::config()->phaxio->{$env}->key.'" ' $cmd .= '-F "api_key='.c::config()->phaxio->{$env}->key.'" '
.'-F "api_secret='.c::config()->phaxio->{$env}->secret.'"'; .'-F "api_secret='.c::config()->phaxio->{$env}->secret.'"';