Пример #1
0
 public static function boot()
 {
     parent::boot();
     static::created(function ($inbound) {
         Pusherer::trigger('boom', 'add_inbound', $inbound);
         Queue::getIron()->addSubscriber('moCallback', array('url' => url('queue/receive')));
         Queue::push('Inbound@moCallback', $inbound->id, 'moCallback');
     });
 }
Пример #2
0
 public static function boot()
 {
     parent::boot();
     static::created(function ($outbound) {
         $outbound = Outbound::find($outbound->id);
         if ($outbound->type != 'whatsapp') {
             Queue::getIron()->addSubscriber('sendMessage', array('url' => url('queue/receive')));
             Queue::push('sendMessage', $outbound->id);
         }
         Pusherer::trigger('boom', 'add_outbound', $outbound);
     });
     static::updated(function ($outbound) {
         Pusherer::trigger('boom', 'update_outbound', $outbound);
     });
 }
Пример #3
0
 public function postSetupNexmo()
 {
     $nexmo_key = Input::get('nexmo_key');
     $nexmo_secret = Input::get('nexmo_secret');
     $nexmo = new NexmoAccount($nexmo_key, $nexmo_secret);
     try {
         // check nexmo credentials
         $credit_balance = $nexmo->getBalance();
         // check db connection
         DB::connection()->getDatabaseName();
         // migrate db
         Artisan::call('migrate');
         // truncate number table
         DB::table('number')->truncate();
         // set nexmo credentials to env
         Cache::forever('NEXMO_KEY', $nexmo_key);
         Cache::forever('NEXMO_SECRET', $nexmo_secret);
         // add numbers to db
         $numbers = $nexmo->getInboundNumbers();
         if ($numbers['count'] > 0) {
             foreach ($numbers['numbers'] as $num) {
                 $number = new Number();
                 $number->number = $num['msisdn'];
                 $number->country_code = $num['country'];
                 $number->type = $num['type'];
                 $number->features = $num['features'];
                 $number->voice_callback_type = $num['voiceCallbackType'];
                 $number->voice_callback_value = $num['voiceCallbackValue'];
                 $number->save();
             }
         }
         // set dn callback url
         // $nexmo->updateAccountSettings(array('drCallBackUrl' => url('callback/dn')));
         Queue::getIron()->addSubscriber('setupDnCallbackUrl', array('url' => url('queue/receive')));
         Queue::push('HomeController@setupDnCallbackUrl', array('nexmo_key' => $nexmo_key, 'nexmo_secret' => $nexmo_secret), 'setupDnCallbackUrl');
         // set balance to cache
         Cache::put('nexmo', $credit_balance, 10);
         if (Auth::check()) {
             return Redirect::to('/');
         }
         return Redirect::to('/register');
     } catch (Exception $e) {
         return Redirect::to('start')->with('message', $e->__toString());
     }
 }
Пример #4
0
 public static function boot()
 {
     parent::boot();
     $nexmo = new NexmoAccount(Cache::get('NEXMO_KEY', getenv('NEXMO_KEY')), Cache::get('NEXMO_SECRET', getenv('NEXMO_SECRET')));
     static::created(function ($number) use($nexmo) {
         Pusherer::trigger('boom', 'add_number', $number);
         // set mo and voice callback url
         Queue::getIron()->addSubscriber('setupNumberCallbackUrl', array('url' => url('queue/receive')));
         Queue::push('Number@setupNumberCallbackUrl', array('nexmo_key' => $nexmo->nexmo_key, 'nexmo_secret' => $nexmo->nexmo_secret, 'country_code' => $number->country_code, 'number' => $number->number), 'setupNumberCallbackUrl');
     });
     static::updating(function ($number) use($nexmo) {
         if ($number->isDirty('voice_callback_type') || $number->isDirty('voice_callback_value')) {
             return $nexmo->updateNumber($number->country_code, $number->number, url('callback/mo'), array('voiceCallbackType' => $number->voice_callback_type, 'voiceCallbackValue' => $number->voice_callback_value, 'voiceStatusCallback' => url('callback/voice')));
         }
         return true;
     });
     static::deleting(function ($number) use($nexmo) {
         return $nexmo->cancelNumber($number->country_code, $number->number);
     });
     static::deleted(function ($number) {
         Pusherer::trigger('boom', 'remove_number', $number);
     });
 }
Пример #5
0
 public static function boot()
 {
     parent::boot();
     static::created(function ($outbound_chunk) {
         $outbound_id = $outbound_chunk->outbound->id;
         // update status outbound
         if ($outbound_chunk->status_code > 0 && isset($status_string[(int) $outbound_chunk->status_code])) {
             $outbound = Outbound::find($outbound_id);
             $outbound->status = strtolower($status_string[(int) $outbound_chunk->status_code]);
             $outbound->save();
         }
     });
     static::updated(function ($outbound_chunk) {
         $outbound_id = $outbound_chunk->outbound->id;
         // update status outbound
         if ($outbound_chunk->dn_error_code >= 0) {
             $outbound = Outbound::find($outbound_id);
             $outbound->status = strtolower($outbound_chunk->dn_status);
             $outbound->save();
             Queue::getIron()->addSubscriber('dnCallback', array('url' => url('queue/receive')));
             Queue::push('OutboundChunk@dnCallback', $outbound_chunk->id, 'dnCallback');
         }
     });
 }
Пример #6
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Queue::getIron()->ssl_verifypeer = false;
Route::get('home', function () {
    return view('welcome');
});
Route::get('', function () {
    return view('welcome');
});
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::post('queue/receive', function () {
    return Queue::marshal();
});
Route::get('empresa', 'EmpresaController@indexempresa');
Route::get('cuenta', 'EmpresaController@cuentaempresa');
Route::get('proyectos', 'EmpresaController@proyectosempresa');
Route::post('proyectos/create', 'EmpresaController@createproyecto');
Route::get('contacto', 'EmpresaController@contactoempresa');
Route::get('personal', 'EmpresaController@personalempresa');
Route::post('updatedatos', 'EmpresaController@updatedatos');
Route::get('getpersonal', 'EmpresaController@getpersonalempresa');