public function actionSendChat() { if (!empty($_POST)) { echo \sintret\chat\ChatRoom::sendChat($_POST); $message = Yii::$app->user->identity->username . ' : ' . $_POST['message']; $pos = strpos($message, "@"); $setting = \app\models\Setting::findOne(1); if ($pos !== FALSE) { // $w = new WhatsApp($number, $app, $password); $usernameSendgrid = $setting->sendgridUsername; $passwordSendgrid = $setting->sendgridPassword; $users = \app\models\User::find()->where(['status' => \app\models\User::STATUS_ACTIVE])->all(); foreach ($users as $model) { $aprot = '@' . strtolower($model->username); if (strpos($message, $aprot) !== false) { $sendgrid = new \SendGrid($usernameSendgrid, $passwordSendgrid, array("turn_off_ssl_verification" => true)); $email = new \SendGrid\Email(); $email->addTo($model->email)->setFrom($setting->emailSupport)->setSubject('Chat from ' . $setting->applicationName)->setHtml($message); $sendgrid->send($email); } else { } } } } }
public function actionChat() { if (!empty($_POST)) { ChatRoom::sendChat($_POST); if (isset($_POST['message'])) { $message = $_POST['message']; } if (isset($post['idRequest'])) { $idRequest = $_POST['idRequest']; } if (isset($post['userName'])) { $userName = $_POST['userName']; } //Estas variables seran requeridas por el que haga el envio de correos se las dejos } }
public function actionChat() { //if (!empty($_POST)) { echo \sintret\chat\ChatRoom::sendChat($_POST); //} }