From 3dec44634810cb80e957682debf70f84cad45885 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Sun, 9 Jun 2024 13:54:14 +0200 Subject: [PATCH 1/4] Update mobile.class.php --- core/class/mobile.class.php | 107 ++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 55 deletions(-) diff --git a/core/class/mobile.class.php b/core/class/mobile.class.php index 887a03b9..a35b800d 100755 --- a/core/class/mobile.class.php +++ b/core/class/mobile.class.php @@ -18,7 +18,7 @@ /* * ***************************Includes********************************* */ require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php'; - +error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); include_file('core', 'bellaMobile', 'class', 'mobile'); class mobile extends eqLogic @@ -580,7 +580,8 @@ public static function getQrCodeV2($userId) public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answer, $timeout, $token, $photo, $version, $optionsNotif = [], $critical = false, $Iq = null) { - if(isset($Iq)) log::add('mobile', 'debug', '| IQ for jsonPublish > ' . $Iq); + log::add('mobile', 'debug', '||┌──:fg-success: jsonPublish :/fg:──'); + if(isset($Iq)) log::add('mobile', 'debug', '||| IQ for jsonPublish > ' . $Iq); $dateNotif = date("Y-m-d H:i:s"); $badge = 0; @@ -795,30 +796,29 @@ public static function jsonPublish($os, $titre, $message, $type, $idNotif, $answ } $notifications[$idNotif] = $publishJson; - log::add('mobile', 'debug', '| Notification enregistrée : ' . json_encode($notifications)); + log::add('mobile', 'debug', '||| [INFO] Notification enregistrée : ' . json_encode($notifications)); file_put_contents($filePath, json_encode($notifications)); } } } - log::add('mobile', 'debug', '| JSON publish > ' . json_encode($publish)); - - + log::add('mobile', 'debug', '||| [INFO] JSON publish > ' . json_encode($publish)); + log::add('mobile', 'debug', '||└────────────────────'); return $publish; } public static function notification($arn, $os, $titre, $message, $type, $idNotif, $answer, $timeout, $token, $photo, $version = 1, $optionsNotif = [], $critical = false, $Iq = null) { - log::add('mobile', 'debug', '| Notification en cours !'); + log::add('mobile', 'debug', '|┌──:fg-success: Notification en cours ! :/fg:──'); $publish = mobile::jsonPublish($os, $titre, $message, $type, $idNotif, $answer, $timeout, $token, $photo, $version, $optionsNotif, $critical, $Iq); if ($token != null) { if ($token == 'notifsBGDisabled') { - log::add('mobile', 'debug', '| NOTIFICATION NON ENVOYEE : LE SERVICE NOTIF EST DESACTIVE SUR LE TELEPHONE'); + log::add('mobile', 'debug', '|| [ERROR] NOTIFICATION NON ENVOYEE : LE SERVICE NOTIF EST DESACTIVE SUR LE TELEPHONE'); message::add(__CLASS__, 'Échec de l\'envoie de notification : le service est désactivé dans les paramètres du téléphone', 'notifsbgSend', 'alertNotifsSend'); return; } if ($token == 'desactivate') { - log::add('mobile', 'debug', '| NOTIFICATION NON ENVOYEE : LES NOTIFICATIONS SONT DESACTIVEES DANS L\'APP : '); + log::add('mobile', 'debug', '|| [ERROR] NOTIFICATION NON ENVOYEE : LES NOTIFICATIONS SONT DESACTIVEES DANS L\'APP : '); message::add(__CLASS__, 'Échec de l\'envoie de notification : le service est désactivé dans les paramètres de l\'application', 'notifsbgSend', 'alertNotifsSend'); return; } @@ -831,14 +831,14 @@ public static function notification($arn, $os, $titre, $message, $type, $idNotif ]; $post = ['message' => $publish, 'options' => $options]; - log::add('mobile', 'debug', '| JSON envoyé en mode FCM > ' . json_encode($post)); + log::add('mobile', 'debug', '|| [INFO] JSON envoyé en mode FCM > ' . json_encode($post)); } elseif ($token == null && $version == 2) { - log::add('mobile', 'debug', '| NOTIFICATION NON ENVOYEE : PAS DE TOKEN ENREGISTRE SUR LE TELEPHONE : '); + log::add('mobile', 'debug', '|| [ERROR] NOTIFICATION NON ENVOYEE : PAS DE TOKEN ENREGISTRE SUR LE TELEPHONE : '); //message::removeAll(__CLASS__, 'noValidToken'); message::add(__CLASS__, '| NOTIFICATION NON ENVOYÉE : PAS DE TOKEN ENREGISTRE SUR LE TÉLÉPHONE :', 'noValidTok', 'noValidToken'); return; } else { - log::add('mobile', 'debug', 'JSON envoyé : APN' . $publish); + log::add('mobile', 'debug', '|| [INFO] JSON envoyé : APN' . $publish); $post = [ 'arn' => $arn, 'text' => $publish, @@ -851,14 +851,16 @@ public static function notification($arn, $os, $titre, $message, $type, $idNotif 'Content-Type: application/json', 'Autorization: ' . sha512(strtolower(config::byKey('market::username')) . ':' . config::byKey('market::password')) )); + //$request_http->setLogError(true); $request_http->setPost(json_encode($post)); $result = json_decode($request_http->exec(30,3), true); if (!isset($result['state']) || $result['state'] != 'ok') { - log::add('mobile', 'info', '| Echec Première Tentative d\'envoi de la notification : '); - log::add('mobile', 'info', '| Nouvelle tentative ....'); + log::add('mobile', 'info', '|| [WARNING] Echec Première Tentative d\'envoi de la notification'); + log::add('mobile', 'info', '|| Nouvelle tentative ....'); sleep(rand(1,10)); $result = json_decode($request_http->exec(30,3), true); } + log::add('mobile', 'debug', '|└────────────────────'); if (!isset($result['state']) || $result['state'] != 'ok') { throw new Exception(__('Echec de l\'envoi de la notification :', __FILE__) . json_encode($result)); } @@ -898,18 +900,17 @@ public function SaveGeoloc($geoloc) public static function createCmdGeoLocV2($Iq, $geolocs) { - log::add('mobile', 'debug', '|-----------------------------------'); - log::add('mobile', 'debug', '| -- GeoLocV2 --'); + log::add('mobile', 'debug', '|┌──:fg-success: GeoLocV2 :/fg:──'); $mobile = eqLogic::byLogicalId($Iq, 'mobile'); if (is_object($mobile)) { - log::add('mobile', 'debug', '| Mobile existant'); - log::add('mobile', 'debug', '| GEOLOCS > ' . $geolocs); + log::add('mobile', 'debug', '|| OK Mobile existant > ' . $mobile->getName()); + log::add('mobile', 'debug', '|| [INFO] GEOLOCS > ' . $geolocs); $noExistCmd = 0; $decodedGeolocs = json_decode($geolocs, true); foreach ($decodedGeolocs as $index => $geoloc) { if (!isset($geoloc['name'])) continue; - log::add('mobile', 'debug', '| Index > ' . $index . ' / ' . $geoloc['name']); + log::add('mobile', 'debug', '|| geoloc_' . $index . ' > ' . $geoloc['name']); $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($mobile->getId(), 'geoloc_' . $index); if (!is_object($cmdgeoloc)) { @@ -922,6 +923,7 @@ public static function createCmdGeoLocV2($Iq, $geolocs) $cmdgeoloc->setIsVisible(1); $cmdgeoloc->setGeneric_type('PRESENCE'); $cmdgeoloc->setIsHistorized(1); + log::add('mobile', 'debug', '|| Ajout geofencing > ' . $geoloc['name']); } $cmdgeoloc->setName($geoloc['name']); $cmdgeoloc->setConfiguration('latitude', $geoloc['latitude']); @@ -930,14 +932,14 @@ public static function createCmdGeoLocV2($Iq, $geolocs) $cmdgeoloc->save(); if ($noExistCmd == 1) { $cmdgeoloc->event($geoloc['value']); - log::add('mobile', 'debug', '| Valeur enregistrée > ' . $geoloc['value']); + log::add('mobile', 'debug', '|| Valeur enregistrée > ' . $geoloc['value']); } $noExistCmd = 0; } - log::add('mobile', 'debug', '|-----------------------------------'); } else { - log::add('mobile', 'debug', 'Mobile inexistant'); + log::add('mobile', 'debug', '| [ERROR] Mobile inexistant !'); } + log::add('mobile', 'debug', '|└────────────────────'); } public function delGeoloc($geoloc) @@ -1079,12 +1081,10 @@ public static function handleMenuDefaultBySelect($eqId, $eqDefault) public static function configMenuCustom($eqId, $jeedomVersion) { - + log::add('mobile', 'debug', '|┌──:fg-success: CONFIGMENU CUSTOM JEEDOM ' . $jeedomVersion . ' :/fg:──'); if ($jeedomVersion < '4.4.0') { - log::add('mobile', 'info', '| -- CONFIGMENU CUSTOM JEEDOM 4.3.0 --'); return $defaultMenuArray = self::getDefaultMenuArray(); } - log::add('mobile', 'info', '| -- CONFIGMENU CUSTOM JEEDOM 4.4.0 --'); $defaultMenuArray = self::getDefaultMenuArray(); $pluginPanelMobile = config::byKey('pluginPanelMobile', 'mobile'); @@ -1118,13 +1118,12 @@ public static function configMenuCustom($eqId, $jeedomVersion) $tabIconName = $resultTabIcon['tabIconName']; $tabLibName = $resultTabIcon['tabLibName']; $tabRenameInput = $resultTabIcon['tabRenameInput']; - - - $objectId = $menuCustomArray[$i]['selectNameMenu']; + //$objectId = $menuCustomArray[$i]['selectNameMenu']; + $objectId = isset($menuCustomArray[$i]['selectNameMenu']) ? $menuCustomArray[$i]['selectNameMenu'] : ''; $isActive = true; $webviewUrl = 'd'; - log::add('mobile', 'debug', '| - objectId > ' . $objectId); + log::add('mobile', 'debug', '|| - objectId > ' . $objectId); // GENERATE URLS FOR MENU CUSTOM $result = self::generateTypeObject($objectId, $i, $webviewUrl, $pluginPanelMobile); @@ -1136,7 +1135,7 @@ public static function configMenuCustom($eqId, $jeedomVersion) if ($count > intval($nbIcones)) { $isActive = false; } - log::add('mobile', 'debug', '| - Construction jsonTemplate'); + //log::add('mobile', 'debug', '| - Construction jsonTemplate'); $jsonTemplate = array( 'active' => $isActive, 'icon' => [ @@ -1156,9 +1155,8 @@ public static function configMenuCustom($eqId, $jeedomVersion) $j++; $count++; } - - log::add('mobile', 'info', '| - Function MobileconfigMenuCustom : ' . json_encode($arrayElements)); - log::add('mobile', 'debug', '|-----------------------------------'); + log::add('mobile', 'debug', '|| [INFO] arrayElements > ' . json_encode($arrayElements)); + log::add('mobile', 'debug', '|└────────────────────'); if (count($arrayElements) == 4) { $j = 0; for ($i = 0; $i < 4; $i++) { @@ -1409,8 +1407,7 @@ class mobileCmd extends cmd public static function fileInMessage($data) { - log::add('mobile', 'debug', '|-----------------------------------'); - log::add('mobile', 'debug', '| -- FileInMessage --'); + log::add('mobile', 'debug', '|┌──:fg-success: fileInMessage :/fg:──'); $dataArray = explode('|', $data); $result = array(); foreach ($dataArray as $item) { @@ -1421,15 +1418,16 @@ public static function fileInMessage($data) } } $result['message'] = $dataArray[0]; - log::add('mobile', 'debug', '| File Parse > ' . json_encode($result)); + log::add('mobile', 'debug', '|| [INFO] File Parse > ' . json_encode($result)); if (array_key_exists('file', $result)) { - log::add('mobile', 'debug', '| file > ' . $result['file']); + log::add('mobile', 'debug', '|| file > ' . $result['file']); + log::add('mobile', 'debug', '|└────────────────────'); return $result; } else { + log::add('mobile', 'debug', '|└────────────────────'); //log::add('mobile', 'debug', '| null'); return null; } - log::add('mobile', 'debug', '|-----------------------------------'); } public function execute($_options = array()) @@ -1437,6 +1435,7 @@ public function execute($_options = array()) if ($this->getType() != 'action') { return; } + log::add('mobile', 'debug', '┌──:fg-success: execute :/fg:──'); $optionsNotif = []; $eqLogic = $this->getEqLogic(); @@ -1457,7 +1456,7 @@ public function execute($_options = array()) $_options['files'] = array(); array_push($_options['files'], $file['file']); $_options['message'] = $file['message']; - log::add('mobile', 'debug', 'file detected ' . json_encode($file)); + log::add('mobile', 'debug', '| file detected ' . json_encode($file)); } $answer = ($_options['answer']) ? join(';', $_options['answer']) : null; @@ -1465,32 +1464,32 @@ public function execute($_options = array()) $askType = ($_options['answer']) ? 'ask_Text' : 'notif'; $timeout = ($_options['timeout']) ? $_options['timeout'] : 'nok'; $optionsNotif['askVariable'] = $askVariable; - log::add('mobile', 'debug', '|-----------------------------------'); - log::add('mobile', 'debug', '| Commande de notification : ' . $askType, 'config'); + //log::add('mobile', 'debug', '|-----------------------------------'); + log::add('mobile', 'debug', '| Commande de notification : ' . $askType); if (($eqLogic->getConfiguration('notificationArn', null) != null || $eqLogic->getConfiguration('notificationRegistrationToken', null) != null) && $eqLogic->getConfiguration('type_mobile', null) != null) { $idNotif = $eqLogic->getConfiguration('idNotif', 0); $idNotif = $idNotif + 1; $eqLogic->setConfiguration('idNotif', $idNotif); $eqLogic->save(); - log::add('mobile', 'debug', '| Notif > ' . json_encode($_options) . ' / ' . $eqLogic->getId() . ' / ' . $this->getLogicalId() . ' / idNotif =' . $idNotif, 'config'); + log::add('mobile', 'debug', '| [INFO] Notif > ' . json_encode($_options)); + log::add('mobile', 'debug', '| eqLogic > ' . $eqLogic->getId() . ' | LogicalId > ' . $this->getLogicalId() . ' | idNotif > ' . $idNotif); if (isset($options['file'])) { - log::add('mobile', 'debug', 'FILE'); - unset($data['file']); + //log::add('mobile', 'debug', '| [NOTICE] FILE'); + //unset($data['file']); $_options['files'] = explode(',', $options['file']); } if (isset($_options['files']) && is_array($_options['files'])) { - log::add('mobile', 'debug', 'FILES'); + log::add('mobile', 'debug', '| [NOTICE] FILE'); foreach ($_options['files'] as $file) { - log::add('mobile', 'debug', 'FILES as FILE'); + log::add('mobile', 'debug', '| FILES as FILE'); if (trim($file) == '') { continue; } - log::add('mobile', 'debug', 'Continue'); $ext = pathinfo($file, PATHINFO_EXTENSION); - log::add('mobile', 'debug', $ext . ' pour > ' . $file); + log::add('mobile', 'debug', '| ' . $ext . ' pour > ' . $file); if (in_array($ext, array('gif', 'jpeg', 'jpg', 'png'))) { - log::add('mobile', 'debug', 'type photo !'); + log::add('mobile', 'debug', '| type photo !'); if ($ext == "gif") { $typeHint = "com.compuserve.gif"; } else if ($ext == "jpeg") { @@ -1508,7 +1507,7 @@ public function execute($_options = array()) $nameFile = base64_encode($file) . '.' . $ext; $path = dirname(__FILE__) . '/../../data/images'; $newfile = $path . '/' . $nameFile; - log::add('mobile', 'debug', 'copie sur > ' . $newfile); + log::add('mobile', 'debug', '| copie sur > ' . $newfile); if (!file_exists($path)) { mkdir($path); } @@ -1517,7 +1516,7 @@ public function execute($_options = array()) } $keyFile = md5_file($newfile); $url .= 'key=' . $keyFile . '&name=' . $nameFile; - log::add('mobile', 'debug', 'url > ' . $url); + log::add('mobile', 'debug', '| url > ' . $url); mobile::notification($eqLogic->getConfiguration('notificationArn', null), $eqLogic->getConfiguration('type_mobile', null), $_options['title'], $_options['message'], $askType, $idNotif, $answer, $timeout, $eqLogic->getConfiguration('notificationRegistrationToken', null), $url, $eqLogic->getConfiguration('appVersion', 1), $optionsNotif, $critical, $eqLogic->getLogicalId()); } else { mobile::notification($eqLogic->getConfiguration('notificationArn', null), $eqLogic->getConfiguration('type_mobile', null), $_options['title'], $_options['message'], $askType, $idNotif, $answer, $timeout, $eqLogic->getConfiguration('notificationRegistrationToken', null), null, $eqLogic->getConfiguration('appVersion', 1), $optionsNotif, $critical, $eqLogic->getLogicalId()); @@ -1526,12 +1525,10 @@ public function execute($_options = array()) } else { mobile::notification($eqLogic->getConfiguration('notificationArn', null), $eqLogic->getConfiguration('type_mobile', null), $_options['title'], $_options['message'], $askType, $idNotif, $answer, $timeout, $eqLogic->getConfiguration('notificationRegistrationToken', null), null, $eqLogic->getConfiguration('appVersion', 1), $optionsNotif, $critical, $eqLogic->getLogicalId()); } - - log::add('mobile', 'debug', '| Action : Envoi d\'une configuration ', 'config'); } else { - log::add('mobile', 'debug', '| ARN non configuré ', 'config'); + log::add('mobile', 'debug', '| [ERROR] ARN non configuré '); } - log::add('mobile', 'debug', '|-----------------------------------'); + log::add('mobile', 'debug', '└────────────────────'); } } From db3f1ad5f100d34c8cb1e657c1c7250f3787c841 Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Sun, 9 Jun 2024 13:55:11 +0200 Subject: [PATCH 2/4] Update mobile.api.php --- core/api/mobile.api.php | 309 ++++++++++++++++++++-------------------- 1 file changed, 151 insertions(+), 158 deletions(-) diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index 47bc7926..053563b1 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -66,21 +66,24 @@ function createMobile($params, $nbIcones = 3) function checkDateMenu($menu, $mobile) { + log::add('mobile', 'debug', '|┌──:fg-success: checkDateMenu :/fg:──'); $dateMobile = $mobile->getConfiguration('DateMenu', 'pasdedate'); + log::add('mobile', 'debug', '|| dateMobile > ' . $dateMobile); + log::add('mobile', 'debug', '|| menu date > ' . (isset($menu['date']) ? $menu['date'] : 'pasdedate')); if (isset($dateMobile) && isset($menu['date'])) { if ($dateMobile < $menu['date']) { - log::add('mobile', 'debug', '| Sauvegarde Menu depuis L APP'); + log::add('mobile', 'debug', '|| OK Sauvegarde Menu depuis l\'App'); saveMenuFromAppV2($menu, $mobile); } - } else { - return; } + log::add('mobile', 'debug', '|└────────────────────'); } function saveMenuFromAppV2($menu, $mobile) { - log::add('mobile', 'debug', '| Menu sauvegarde FRM / APPV2 ' . json_encode($menu)); + log::add('mobile', 'debug', '||┌── :fg-success:saveMenuFromAppV2:/fg: ──'); + log::add('mobile', 'debug', '||| [INFO] Menu > ' . json_encode($menu)); if (is_object($mobile)) { $menuCustomArray = []; $count = 0; @@ -110,26 +113,31 @@ function saveMenuFromAppV2($menu, $mobile) $mobile->setConfiguration('nbIcones', $count); $mobile->save(); } + log::add('mobile', 'debug', '||└───────────────────'); } $params = $jsonrpc->getParams(); -log::add('mobile', 'debug', '|------------------------------------------------------------------------------------------------------|'); -log::add('mobile', 'debug', '| Appel API Mobile > ' . $jsonrpc->getMethod()); +log::add('mobile', 'debug', '┌──────────▶︎ :fg-warning: Appel API Mobile :/fg: ◀︎───────────'); +log::add('mobile', 'debug', '| Method > ' . $jsonrpc->getMethod()); log::add('mobile', 'debug', '| Paramètres passés > ' . json_encode($params)); if ($params['Iq']) { log::add('mobile', 'debug', '| Mobile demandeur > ' . mobile::whoIsIq($params['Iq'])); } -log::add('mobile', 'debug', '|-----------------------------------'); +else { + log::add('mobile', 'debug', '| [WARNING] Paramètre Iq inexistant !'); +} +log::add('mobile', 'debug', '└───────────────────────────────────────────'); if ($jsonrpc->getMethod() == 'setConfigs') { - log::add('mobile', 'debug', '| App V2 Demande > ' . $jsonrpc->getMethod()); - //log::add('mobile', 'debug', 'APRAMS > ' . json_encode($params)); + log::add('mobile', 'debug', '┌─────▶︎ AppV2 setConfigs ─────────────────'); $configs = $params['configs']; + $geolocs = $params['geolocs']; $menu = $configs['menu']; $notification = $configs['notification']; - log::add('mobile', 'debug', '| Configs > ' . json_encode($configs)); - log::add('mobile', 'debug', '| Menu > ' . json_encode($menu)); - log::add('mobile', 'debug', '| Notification > ' . json_encode($notification)); + log::add('mobile', 'debug', '| [INFO] Configs > ' . json_encode($configs)); + log::add('mobile', 'debug', '| [INFO] Geolocs > ' . json_encode($geolocs)); + log::add('mobile', 'debug', '| [INFO] Menu > ' . json_encode($menu)); + log::add('mobile', 'debug', '| [INFO] Notification > ' . json_encode($notification)); $mobile = null; if (isset($params['Iq'])) { $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'); @@ -138,21 +146,20 @@ function saveMenuFromAppV2($menu, $mobile) $mobile = createMobile($params, 3); } if (isset($notification['token'])) { - log::add('mobile', 'debug', '| Token à ajouter > ' . $notification['token']); - if ($notification['token'] == 'notifsBGDisabled') { - message::removeAll("mobile", 'alertNotifs'); - $phoneName = $mobile->getName(); - message::add('mobile', 'Les notifications sur votre mobile : ' . $phoneName . ' sont desactivées', 'notifsbg', 'alertNotifs'); - } if ($notification['token'] != '') { + log::add('mobile', 'debug', '| Token à ajouter > ' . $notification['token']); $mobile->setConfiguration('notificationRegistrationToken', $notification['token']); - } + if ($notification['token'] == 'notifsBGDisabled') { + message::removeAll("mobile", 'alertNotifs'); + message::add('mobile', 'Les notifications sur votre mobile : ' . $mobile->getName() . ' sont desactivées', 'notifsbg', 'alertNotifs'); + } + } else { + log::add('mobile', 'debug', '| [NOTICE] Token vide '); + } } $mobile->save(); // TEMPORAIREMENT DESACTIVE checkDateMenu($menu, $mobile); - $geolocs = $params['geolocs']; - log::add('mobile', 'debug', '| Geolocs > ' . json_encode($geolocs)); if ($geolocs) { if ($geolocs != [] && !(is_object($geolocs) && empty((array)$geolocs)) && !(is_string($geolocs) && $geolocs == "{}")) { mobile::createCmdGeoLocV2($params['Iq'], $params['geolocs']); @@ -169,17 +176,12 @@ function saveMenuFromAppV2($menu, $mobile) } } } - // mobile::createCmdGeoLocV2($params); + log::add('mobile', 'debug', '└───────────────────────────────────────────'); $jsonrpc->makeSuccess('ok'); } - - - if ($jsonrpc->getMethod() == 'getJson') { - - //log::add('mobile', 'debug', '| Demande du RDK to get Json'); - //log::add('mobile', 'debug', '| Demande du RDK'); + log::add('mobile', 'debug', '┌─────◀︎ AppV2 getJson ────────────────────'); $registerDevice = $_USER_GLOBAL->getOptions('registerDevice', array()); if (!is_array($registerDevice)) { $registerDevice = array(); @@ -192,11 +194,9 @@ function saveMenuFromAppV2($menu, $mobile) $_USER_GLOBAL->setOptions('registerDevice', $registerDevice); $_USER_GLOBAL->save(); log::add('mobile', 'debug', '| RDK :' . $rdk); - log::add('mobile', 'debug', '| Demande du GetJson'); $idBox = jeedom::getHardwareKey(); $return = array(); /* -------- MOBILE FIRST ------- */ - log::add('mobile', 'debug', '| Creation du retour de base pour l\'APP'); $objectsDashboard = []; foreach (jeeObject::all() as $object) { $obArray = utils::o2a($object); @@ -280,7 +280,7 @@ function saveMenuFromAppV2($menu, $mobile) $categories[$value['icon']] = $value['name']; } $return[$idBox]['informations']['objects']['categories'] = $categories; - sleep(1); + //sleep(1); $coreData = []; $resultCore = utils::o2a(update::byLogicalId('jeedom')); array_push($coreData, $resultCore); @@ -294,17 +294,16 @@ function saveMenuFromAppV2($menu, $mobile) $return[$idBox]['jeedom_version'] = jeedom::version(); $return[$idBox]['rdk'] = $rdk; $return[$idBox]['name'] = config::byKey('name') == '' ? 'Jeedom' : config::byKey('name'); - log::add('mobile', 'debug', '| Retour de base > ' . json_encode($return)); - + log::add('mobile', 'debug', '| [INFO] Retour de base > ' . json_encode($return)); log::add('mobile', 'debug', '| Recherche du mobile via sont Iq > ' . $params['Iq']); $mobile = eqLogic::byLogicalId($params['Iq'], 'mobile'); - log::add('mobile', 'debug', '| Mobile object'); $return[$idBox]['configs'] = array(); if (is_object($mobile)) { - log::add('mobile', 'debug', '| Mobile bien trouvé > ' . $mobile->getName()); + log::add('mobile', 'debug', '| OK Mobile trouvé > ' . $mobile->getName()); $return[$idBox]['configs']['menu'] = mobile::configMenuCustom($mobile->getId(), jeedom::version()); } else { if (jeedom::version() < '4.4.0') { + log::add('mobile', 'debug', '| [WARNING] Version du core > ' . jeedom::version()); $return[$idBox]['configs']['menu'] = mobile::configMenuCustom($mobile->getId(), jeedom::version()); } else { $defaultMenuJson = '{"tab0":{"active":true,"icon":{"name":"in","type":"jeedomapp"},"name":"Accueil","options":{"uri":"\/index.php?v=m&p=home"},"type":"WebviewApp"}, @@ -337,8 +336,9 @@ function saveMenuFromAppV2($menu, $mobile) } config::save('menuCustom_' . $params['Iq'], $newMenu, 'mobile'); - log::add('mobile', 'debug', '| CustomENVOICONFIGSAPI GETJSON > ' . json_encode($return[$idBox]['configs'])); - log::add('mobile', 'debug', '| INFOS GETJSONINITAL > ' . json_encode($return)); + log::add('mobile', 'debug', '| [INFO] CustomENVOICONFIGSAPI GETJSON > ' . json_encode($return[$idBox]['configs'])); + log::add('mobile', 'debug', '| [INFO] Retour vers App > ' . json_encode($return)); + log::add('mobile', 'debug', '└───────────────────────────────────────────'); $jsonrpc->makeSuccess($return); } @@ -351,7 +351,6 @@ function saveMenuFromAppV2($menu, $mobile) $jsonrpc->makeSuccess("false"); } - if ($jsonrpc->getMethod() == 'deleteAllMessageByType') { if (isset($params['appInfos']['messageType'])) { if ($params['appInfos']['messageType'] == 'jeedom') { @@ -375,9 +374,6 @@ function saveMenuFromAppV2($menu, $mobile) } } - - - if ($jsonrpc->getMethod() == 'sync') { if (jeedom::version() >= '3.2.0') { log::add('mobile', 'debug', 'SYNC'); @@ -506,8 +502,7 @@ function saveMenuFromAppV2($menu, $mobile) } if ($jsonrpc->getMethod() == 'askText') { - log::add('mobile', 'debug', '|-----------------------------------'); - log::add('mobile', 'debug', '| -- ASK --'); + log::add('mobile', 'debug', '┌─────▶︎ ASK ───────────────────────────────'); /*$configs = $params['configs']; $menu = $configs['menu']; $notification = $configs['notification'];*/ @@ -522,17 +517,19 @@ function saveMenuFromAppV2($menu, $mobile) log::add('mobile', 'debug', '| Réponse : ' . $textCasse . ' - IQ > ' . $params['Iq'] . ' -- Demande cmd > ' . $cmd->getId()); if ($cmd->askResponse($textCasse)) { log::add('mobile', 'debug', '| ASK bien trouvé : Réponse validée'); - $jsonrpc->makeSuccess(); } else { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $cmd->generateAskResponseLink($params['text'])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); - log::add('mobile', 'debug', $output); - $jsonrpc->makeSuccess(); + if (!empty($output)) log::add('mobile', 'debug', '| ' . $output); } + } else { + log::add('mobile', 'debug', __('| [ERROR] EqLogic inconnu : ', __FILE__) . $params['Iq']); } + log::add('mobile', 'debug', '└───────────────────────────────────────────'); + $jsonrpc->makeSuccess(); } if ($jsonrpc->getMethod() == 'saveMobile') { @@ -571,32 +568,32 @@ function saveMenuFromAppV2($menu, $mobile) if ($jsonrpc->getMethod() == 'mobile::geoloc') { - log::add('mobile', 'debug', '|-----------------------------------'); - log::add('mobile', 'debug', '| -- GeoLocV2 geofencing --'); - + log::add('mobile', 'debug', '┌─────▶︎ GeoLocV2 geofencing ───────────────'); if (isset($params['transmition']) && isset($params['transmition']['event']) && $params['transmition']['event'] == 'geofence') { log::add('mobile', 'debug', '| Event > ' . $params['transmition']['event']); $geofence = $params['transmition']['geofence']; log::add('mobile', 'debug', '| Event > ' . json_encode($geofence)); $eqLogicMobile = eqLogic::byLogicalId($params['Iq'], 'mobile'); if ($eqLogicMobile) { - log::add('mobile', 'debug', '| Mobile trouvé : ' . $params['Iq']); + log::add('mobile', 'debug', '| OK Mobile trouvé -> ' . $eqLogicMobile->getName() . ' (' . $params['Iq'] . ')'); //PR $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoloc_' . $geofence['identifier']); if (is_object($cmdgeoloc)) { - log::add('mobile', 'debug', '| Commande trouvé'); if ($geofence['action'] == 'ENTER') { - log::add('mobile', 'debug', '| Commande passée à 1'); + log::add('mobile', 'debug', '| OK Commande "'. $cmdgeoloc->getName() . '" passée à 1'); $cmdgeoloc->event(1); } elseif ($geofence['action'] == 'EXIT') { - log::add('mobile', 'debug', '| Commande passée à 0'); + log::add('mobile', 'debug', '| OK Commande "'. $cmdgeoloc->getName() . '" passée à 0'); $cmdgeoloc->event(0); } + else { + log::add('mobile', 'debug', '| Event -> ' . $geofence['action']); + } } - log::add('mobile', 'debug', '|-----------------------------------'); - $jsonrpc->makeSuccess(); + } elseif (isset($params['Iq'])) { + log::add('mobile', 'debug', __('| [ERROR] EqLogic inconnu : ', __FILE__) . $params['Iq']); } else { - throw new Exception(__('EqLogic inconnu : ', __FILE__) . $params['Iq']); - } + log::add('mobile', 'debug', __('| [ERROR] Paramètre Iq inexistant !', __FILE__)); + } } else { $transmitions = $params['transmition']; $errorCount = 0; @@ -607,75 +604,78 @@ function saveMenuFromAppV2($menu, $mobile) log::add('mobile', 'debug', '| Event > ' . json_encode($geofence)); $eqLogicMobile = eqLogic::byLogicalId($params['Iq'], 'mobile'); if ($eqLogicMobile) { - log::add('mobile', 'debug', '| Mobile trouvé'); + log::add('mobile', 'debug', '| OK Mobile trouvé -> ' . $eqLogicMobile->getName() . ' (' . $params['Iq'] . ')'); //PR $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoloc_' . $geofence['identifier']); if (is_object($cmdgeoloc)) { - log::add('mobile', 'debug', '| Commande trouvé'); if ($geofence['action'] == 'ENTER') { - log::add('mobile', 'debug', '| Commande passé à 1'); + log::add('mobile', 'debug', '| OK Commande "'. $cmdgeoloc->getName() . '" passée à 1'); $cmdgeoloc->event(1); } elseif ($geofence['action'] == 'EXIT') { - log::add('mobile', 'debug', '| Commande passé à 0'); + log::add('mobile', 'debug', '| OK Commande "'. $cmdgeoloc->getName() . '" passée à 0'); $cmdgeoloc->event(0); } else { - log::add('mobile', 'debug', '| Event DWELL'); + log::add('mobile', 'debug', '| [INFO] Event -> ' . $geofence['action']); //PR } + } else { + log::add('mobile', 'debug', '| [ERROR] Commande geoloc_' . $geofence['identifier'] . ' inexistante.'); } } else { - throw new Exception(__('EqLogic inconnu : ', __FILE__) . $params['Iq']); + log::add('mobile', 'debug', __('| [ERROR] EqLogic inconnu : ', __FILE__) . $params['Iq']); } - log::add('mobile', 'debug', '|-----------------------------------'); } else { $errorCount++; } } - if ($errorCount == 0) { - $jsonrpc->makeSuccess(); - } else { - throw new Exception(__('pas de parametre de geofencing : ', __FILE__)); + if ($errorCount > 0) { + log::add('mobile', 'error', __('| Pas de paramètre de geofencing', __FILE__)); } } + log::add('mobile', 'debug', '└───────────────────────────────────────────'); + $jsonrpc->makeSuccess(); } if ($jsonrpc->getMethod() == "qrcodemethod") { - log::add('mobile', 'debug', 'QrCode > ' . json_encode($params)); + log::add('mobile', 'debug', '┌─────▶︎ qrcodemethod ──────────────────────'); if ($params['appInfos']) { - log::add('mobile', 'debug', 'valeur du QrCode > ' . json_encode($params['appInfos']['qrCode'])); + log::add('mobile', 'debug', '| [INFO] Valeur du QrCode > ' . json_encode($params['appInfos']['qrCode'])); if (isset($params['appInfos']['qrCode']['displayValue'])) { mobile::cmdForApi($params['Iq'], "barrecodemethod", $params['appInfos']['qrCode']['displayValue'], "CodeBarre"); } else { mobile::cmdForApi($params['Iq'], "qrcodemethod", json_encode($params['appInfos']['qrCode']), "QrCode"); } - $jsonrpc->makeSuccess(); + log::add('mobile', 'debug', '└───────────────────────────────────────────'); } + $jsonrpc->makeSuccess(); } if ($jsonrpc->getMethod() == "nfc") { + log::add('mobile', 'debug', '┌─────▶︎ nfc ───────────────────────────────'); $id = (isset($params['appInfos']['payload']['id'])) ? $params['appInfos']['payload']['id'] : ""; $payload = (isset($params['appInfos']['payload']['payload'])) ? $params['appInfos']['payload']['payload'] : ""; mobile::cmdForApi($params['Iq'], "nfcId", $id, "Nfc Id"); mobile::cmdForApi($params['Iq'], "nfcPayload", json_encode($payload), "Nfc Payload"); - - log::add('mobile', 'debug', '| Id > ' . $id); - log::add('mobile', 'debug', '| Payload > ' . $payload); - + log::add('mobile', 'debug', '| [INFO] Id > ' . $id); + log::add('mobile', 'debug', '| [INFO] Payload > ' . $payload); + log::add('mobile', 'debug', '└───────────────────────────────────────────'); $jsonrpc->makeSuccess(); } if ($jsonrpc->getMethod() == "syncBella") { - log::add('mobile', 'debug', 'JeedomApp > syncBella'); + log::add('mobile', 'debug', '┌─────▶︎ syncBella ─────────────────────────'); + log::add('mobile', 'debug', '| JeedomApp > syncBella'); + log::add('mobile', 'debug', '└───────────────────────────────────────────'); } if ($jsonrpc->getMethod() == 'getNotificationsFromFile') { - //log::add('mobile', 'debug', '| Get notifications from file'); + log::add('mobile', 'debug', '┌────◀︎ getNotificationsFromFile ──────────'); $Iq = $params['Iq']; $filePath = dirname(__FILE__) . '/../data/notifications/' . $Iq . '.json'; + $notifications = 'noNotifications'; if (file_exists($filePath)) { $notifications = file_get_contents($filePath); if ($notifications) { $notifications = json_decode($notifications, true); foreach ($notifications as $id => $value) { - //$data = json_decode($value['data'], true); $dateNew = substr($value['data']['date'], 0, 10); $horaire = substr($value['data']['date'], -8); $horaireFormat = substr($horaire, 0, 5); @@ -683,62 +683,63 @@ function saveMenuFromAppV2($menu, $mobile) $notifications[$id]['data']['horaireFormat'] = $horaireFormat; } $notifications = json_encode($notifications); - $jsonrpc->makeSuccess($notifications); - } else { - $jsonrpc->makeSuccess('noNotifications'); } - } else { - $jsonrpc->makeSuccess('noNotifications'); } + log::add('mobile', 'debug', '| [INFO] Notifications > ' . $notifications); + log::add('mobile', 'debug', '└───────────────────────────────────────────'); //PR + $jsonrpc->makeSuccess($notifications); } if ($jsonrpc->getMethod() == 'deleteNotificationInJsonFile') { + log::add('mobile', 'debug', '┌────▶︎ deleteNotificationInJsonFile ──────'); $Iq = $params['Iq']; + $filePath = dirname(__FILE__) . '/../data/notifications/' . $Iq . '.json'; $idNotif = $params['IdNotif']; - log::add('mobile', 'debug', 'Delete notification in file > ' . $Iq . ' > ' . $idNotif); - $pathNotification = __DIR__ . '/../data/notifications'; - if (file_exists($pathNotification)) { - $notifications = file_get_contents($pathNotification . '/' . $Iq . '.json'); + log::add('mobile', 'debug', '| [WARNING] Delete notification "' . $idNotif . '" in file > ' . $filePath); + if (file_exists($filePath)) { + $notifications = file_get_contents($filePath); $notificationsArray = json_decode($notifications, true); if ($idNotif == 'allNotifs') { - file_put_contents($pathNotification . '/' . $Iq . '.json', ''); - $jsonrpc->makeSuccess('ok'); - return; + file_put_contents($filePath, ''); } - if (isset($notificationsArray[$idNotif])) { + elseif (isset($notificationsArray[$idNotif])) { unset($notificationsArray[$idNotif]); + $notifications = json_encode($notificationsArray); + file_put_contents($filePath, $notifications); } - - $notifications = json_encode($notificationsArray); - file_put_contents($pathNotification . '/' . $Iq . '.json', $notifications); - - $jsonrpc->makeSuccess('ok'); + log::add('mobile', 'debug', '└───────────────────────────────────────────'); //PR } + $jsonrpc->makeSuccess('ok'); } if ($jsonrpc->getMethod() == 'deleteGeolocCommand') { - log::add('mobile', 'debug', '| -- Commande suppression GeoLoc --'); + log::add('mobile', 'debug', '┌────▶︎ Commande suppression GeoLoc ───────'); log::add('mobile', 'debug', '| Paramètres > ' . json_encode($params)); $geolocId = $params['geoloc_id']; $eqLogic = eqLogic::byLogicalId($params['Iq'], 'mobile'); if (is_object($eqLogic)) { $cmd = cmd::byEqLogicIdAndLogicalId($eqLogic->getId(), 'geoloc_' . $geolocId); if (is_object($cmd)) { + log::add('mobile', 'debug', '| [WARNING] Suppression de la commande "' . $cmd->getName() . '"'); $cmd->remove(); } - $jsonrpc->makeSuccess('ok'); + } else { + log::add('mobile', 'debug', __('| [ERROR] EqLogic inconnu : ', __FILE__) . $params['Iq']); } + log::add('mobile', 'debug', '└───────────────────────────────────────────'); + $jsonrpc->makeSuccess('ok'); } if ($jsonrpc->getMethod() == 'getAskResponse') { + log::add('mobile', 'debug', '┌────▶︎ getAskResponse ────────────────────'); $Iq = $params['Iq']; + $filePath = dirname(__FILE__) . '/../data/notifications/' . $Iq . '.json'; $idNotif = $params['idNotif']; $choiceAsk = $params['choiceAsk']; log::add('mobile', 'debug', '| Réponse ASK > ' . $Iq . ' > ' . $idNotif . ' > ' . $choiceAsk); - $pathNotification = __DIR__ . '/../data/notifications'; - if (file_exists($pathNotification)) { - $notifications = file_get_contents($pathNotification . '/' . $Iq . '.json'); + if (file_exists($filePath)) { + $notifications = file_get_contents($filePath); $notificationsArray = json_decode($notifications, true); foreach ($notificationsArray as $key => $notif) { if ($notif['data']['idNotif'] == $idNotif) { @@ -747,19 +748,19 @@ function saveMenuFromAppV2($menu, $mobile) } } $updatedNotifications = json_encode($notificationsArray); - file_put_contents($pathNotification . '/' . $Iq . '.json', $updatedNotifications); + file_put_contents($filePath, $updatedNotifications); } + log::add('mobile', 'debug', '└───────────────────────────────────────────'); $jsonrpc->makeSuccess('ok'); } -if($jsonrpc->getMethod() == 'getScenarios'){ - log::add('mobile', 'debug', '|Gest Scenarios'); +if ($jsonrpc->getMethod() == 'getScenarios'){ + log::add('mobile', 'debug', '┌────◀︎ Get Scénarios ─────────────────────'); $scenarios = array(); $hasScenario = false; - $scenarioListGroup = scenario::listGroup(); - if(empty($scenarioListGroup)){ - log::add('mobile', 'debug', '|Scenarios > Aucun groupe de scénario'); + if (empty($scenarioListGroup)){ + log::add('mobile', 'debug', '| Scénarios > Aucun groupe de scénario'); $emptyListGroup = true; } if (is_array($scenarioListGroup)) { @@ -772,66 +773,58 @@ function saveMenuFromAppV2($menu, $mobile) if (count($scenarioNoGroup) > 0) { $scenarios['{{Aucun}}'] = $scenarioNoGroup; $hasScenario = true; - }else{ - log::add('mobile', 'debug', '|Scenarios > Aucun sans groupe de scénario'); + } else { + log::add('mobile', 'debug', '| Scénarios > Aucun "sans groupe" de scénario'); $emptyNoGroup = true; } - - log::add('mobile', 'debug', '|Scenarios > ' . json_encode($scenarios)); + log::add('mobile', 'debug', '| Scénarios > ' . json_encode($scenarios)); $scenarioTemp = array(); - foreach($scenarios as $key => $scenario){ + foreach ($scenarios as $key => $scenario){ $scenarioTemp[$key][] = utils::o2a($scenario); } - log::add('mobile', 'debug', '|ScenariosTemp > ' . json_encode($scenarioTemp)); - - if($emptyListGroup && $emptyNoGroup){ - $jsonrpc->makeSuccess('noScenarios'); - return; - }else{ - $scenarios = json_encode($scenarioTemp); - $jsonrpc->makeSuccess($scenarios); + log::add('mobile', 'debug', '| $scenarioTemp > ' . json_encode($scenarioTemp)); + if ($emptyListGroup && $emptyNoGroup){ + $return = 'noScenarios'; + } else { + $return = json_encode($scenarioTemp); } - + log::add('mobile', 'debug', '└───────────────────────────────────────────'); + $jsonrpc->makeSuccess($return); } - -if($jsonrpc->getMethod() == 'handleScenario'){ - $scenarioId = $params['scenario_id']; - $action = $params['action']; - - switch($action){ - case 'start': if(is_object($scenario = scenario::byId($scenarioId))){ - $scenario->launch(); - $jsonrpc->makeSuccess('ok'); - }else{ - $jsonrpc->makeSuccess('ko'); - } - break; - case 'stop': if(is_object($scenario = scenario::byId($scenarioId))){ - $scenario->stop(); - $jsonrpc->makeSuccess('ok'); - }else{ - $jsonrpc->makeSuccess('ko'); - } - break; - case 'activate': if(is_object($scenario = scenario::byId($scenarioId))){ - $scenario->setIsActive(1); - $scenario->save(); - $jsonrpc->makeSuccess('ok'); - }else{ - $jsonrpc->makeSuccess('ko'); - } - break; - case 'desactivate': if(is_object($scenario = scenario::byId($scenarioId))){ - $scenario->setIsActive(0); - $scenario->save(); - $jsonrpc->makeSuccess('ok'); - }else{ - $jsonrpc->makeSuccess('ko'); - } - break; +if ($jsonrpc->getMethod() == 'handleScenario'){ + log::add('mobile', 'debug', '┌────▶︎ handleScenario ────────────────────'); + $scenarioId = $params['scenario_id']; + $action = $params['action']; + $result = 'ko'; + log::add('mobile', 'debug', '| Scénario > ' . $scenarioId); + log::add('mobile', 'debug', '| Action > ' . $action); + if (is_object($scenario = scenario::byId($scenarioId))) { + switch($action) { + case 'start': + $scenario->launch(); + $result = 'ok'; + break; + case 'stop': + $scenario->stop(); + $result = 'ok'; + break; + case 'activate': + $scenario->setIsActive(1); + $scenario->save(); + $result = 'ok'; + break; + case 'desactivate': + $scenario->setIsActive(0); + $scenario->save(); + $result = 'ok'; + break; + } + } else { + log::add('mobile', 'debug', '| [ERROR] Scénario > ' . $scenarioId . ' inexistant !'); } - + log::add('mobile', 'debug', '└───────────────────────────────────────────'); + $jsonrpc->makeSuccess($result); } From c28c0e592a3958c6a4af3e84b31aa92e3792bf1d Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:37:34 +0200 Subject: [PATCH 3/4] Update mobile.api.php --- core/api/mobile.api.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index 053563b1..3519da45 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -575,7 +575,7 @@ function saveMenuFromAppV2($menu, $mobile) log::add('mobile', 'debug', '| Event > ' . json_encode($geofence)); $eqLogicMobile = eqLogic::byLogicalId($params['Iq'], 'mobile'); if ($eqLogicMobile) { - log::add('mobile', 'debug', '| OK Mobile trouvé -> ' . $eqLogicMobile->getName() . ' (' . $params['Iq'] . ')'); //PR + log::add('mobile', 'debug', '| OK Mobile trouvé -> ' . $eqLogicMobile->getName() . ' (' . $params['Iq'] . ')'); $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoloc_' . $geofence['identifier']); if (is_object($cmdgeoloc)) { if ($geofence['action'] == 'ENTER') { @@ -604,7 +604,7 @@ function saveMenuFromAppV2($menu, $mobile) log::add('mobile', 'debug', '| Event > ' . json_encode($geofence)); $eqLogicMobile = eqLogic::byLogicalId($params['Iq'], 'mobile'); if ($eqLogicMobile) { - log::add('mobile', 'debug', '| OK Mobile trouvé -> ' . $eqLogicMobile->getName() . ' (' . $params['Iq'] . ')'); //PR + log::add('mobile', 'debug', '| OK Mobile trouvé -> ' . $eqLogicMobile->getName() . ' (' . $params['Iq'] . ')'); $cmdgeoloc = cmd::byEqLogicIdAndLogicalId($eqLogicMobile->getId(), 'geoloc_' . $geofence['identifier']); if (is_object($cmdgeoloc)) { if ($geofence['action'] == 'ENTER') { @@ -614,7 +614,7 @@ function saveMenuFromAppV2($menu, $mobile) log::add('mobile', 'debug', '| OK Commande "'. $cmdgeoloc->getName() . '" passée à 0'); $cmdgeoloc->event(0); } else { - log::add('mobile', 'debug', '| [INFO] Event -> ' . $geofence['action']); //PR + log::add('mobile', 'debug', '| [INFO] Event -> ' . $geofence['action']); } } else { log::add('mobile', 'debug', '| [ERROR] Commande geoloc_' . $geofence['identifier'] . ' inexistante.'); @@ -627,7 +627,7 @@ function saveMenuFromAppV2($menu, $mobile) } } if ($errorCount > 0) { - log::add('mobile', 'error', __('| Pas de paramètre de geofencing', __FILE__)); + log::add('mobile', 'debug', __('| Pas de paramètre de geofencing', __FILE__)); } } log::add('mobile', 'debug', '└───────────────────────────────────────────'); @@ -686,7 +686,7 @@ function saveMenuFromAppV2($menu, $mobile) } } log::add('mobile', 'debug', '| [INFO] Notifications > ' . $notifications); - log::add('mobile', 'debug', '└───────────────────────────────────────────'); //PR + log::add('mobile', 'debug', '└───────────────────────────────────────────'); $jsonrpc->makeSuccess($notifications); } @@ -708,7 +708,7 @@ function saveMenuFromAppV2($menu, $mobile) $notifications = json_encode($notificationsArray); file_put_contents($filePath, $notifications); } - log::add('mobile', 'debug', '└───────────────────────────────────────────'); //PR + log::add('mobile', 'debug', '└───────────────────────────────────────────'); } $jsonrpc->makeSuccess('ok'); } From a50e0a29f94ef7680b637932fc169e892507905a Mon Sep 17 00:00:00 2001 From: David <79108364+Phpvarious@users.noreply.github.com> Date: Fri, 14 Jun 2024 20:07:25 +0200 Subject: [PATCH 4/4] Update mobile.api.php --- core/api/mobile.api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index 3519da45..250cfde3 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -598,7 +598,7 @@ function saveMenuFromAppV2($menu, $mobile) $transmitions = $params['transmition']; $errorCount = 0; foreach ($transmitions as $transmition) { - if ($transmition['event'] == 'geofence') { + if (isset($transmition['event']) && $transmition['event'] == 'geofence') { log::add('mobile', 'debug', '| Transmition :' . json_encode($params['transmition'])); $geofence = $transmition['geofence']; log::add('mobile', 'debug', '| Event > ' . json_encode($geofence));