diff --git a/VERSION b/VERSION index 5d7c78b..50dde2d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.6.4 +v3.6.3 diff --git a/adapters/AdapterInterface.php b/adapters/AdapterInterface.php index 0371436..5de6a5c 100644 --- a/adapters/AdapterInterface.php +++ b/adapters/AdapterInterface.php @@ -161,7 +161,7 @@ interface AdapterInterface /** * Method called to verify phone status * - * @return string : Return one phone status among 'available', 'unavailable', 'no_credit', 'limit_reached' + * @return string : Return one phone status among 'available', 'unavailable', 'no_credit' */ public function check_phone_status(): string; diff --git a/controllers/publics/Api.php b/controllers/publics/Api.php index 57a4b44..c2e0636 100644 --- a/controllers/publics/Api.php +++ b/controllers/publics/Api.php @@ -1030,37 +1030,10 @@ namespace controllers\publics; return $this->json($return); } - // If user have activated phone limits, check if RaspiSMS phone limit have already been reached - $limit_reached = false; - if ((int) ($this->user['settings']['phone_limit'] ?? false)) - { - $limits = $this->internal_phone->get_limits($id); - - $remaining_volume = PHP_INT_MAX; - foreach ($limits as $limit) - { - $startpoint = new \DateTime($limit['startpoint']); - $consumed = $this->internal_sended->count_since_for_phone_and_user($this->user['id'], $id, $startpoint); - $remaining_volume = min(($limit['volume'] - $consumed), $remaining_volume); - } - - if ($remaining_volume < 1) - { - $limit_reached = true; - } - } - - if ($limit_reached) - { - $new_status = \models\Phone::STATUS_LIMIT_REACHED; - } - else - { - //Check status on provider side - $adapter_classname = $phone['adapter']; - $adapter_instance = new $adapter_classname($phone['adapter_data']); - $new_status = $adapter_instance->check_phone_status(); - } + //Check adapter is working correctly with thoses names and data + $adapter_classname = $phone['adapter']; + $adapter_instance = new $adapter_classname($phone['adapter_data']); + $new_status = $adapter_instance->check_phone_status(); $status_update = $this->internal_phone->update_status($id, $new_status); $return['response'] = $new_status; diff --git a/controllers/publics/Phone.php b/controllers/publics/Phone.php index ef06f7b..3ce81e0 100644 --- a/controllers/publics/Phone.php +++ b/controllers/publics/Phone.php @@ -18,13 +18,11 @@ class Phone extends \descartes\Controller { private $internal_phone; private $internal_adapter; - private $internal_sended; public function __construct() { $bdd = \descartes\Model::_connect(DATABASE_HOST, DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD); $this->internal_phone = new \controllers\internals\Phone($bdd); - $this->internal_sended = new \controllers\internals\Sended($bdd); $this->internal_adapter = new \controllers\internals\Adapter(); \controllers\internals\Tool::verifyconnect(); @@ -535,43 +533,16 @@ class Phone extends \descartes\Controller foreach ($ids as $id) { $phone = $this->internal_phone->get_for_user($id_user, $id); - - // If user have activated phone limits, check if RaspiSMS phone limit have already been reached - $limit_reached = false; - if ((int) ($_SESSION['user']['settings']['phone_limit'] ?? false)) + + //Check adapter is working correctly with thoses names and data + $adapter_classname = $phone['adapter']; + if (!call_user_func([$adapter_classname, 'meta_support_phone_status'])) { - $limits = $this->internal_phone->get_limits($id); - - $remaining_volume = PHP_INT_MAX; - foreach ($limits as $limit) - { - $startpoint = new \DateTime($limit['startpoint']); - $consumed = $this->internal_sended->count_since_for_phone_and_user($_SESSION['user']['id'], $id, $startpoint); - $remaining_volume = min(($limit['volume'] - $consumed), $remaining_volume); - } - - if ($remaining_volume < 1) - { - $limit_reached = true; - } + continue; } - if ($limit_reached) - { - $new_status = \models\Phone::STATUS_LIMIT_REACHED; - } - else - { - //Check status on provider side - $adapter_classname = $phone['adapter']; - if (!call_user_func([$adapter_classname, 'meta_support_phone_status'])) - { - continue; - } - - $adapter_instance = new $adapter_classname($phone['adapter_data']); - $new_status = $adapter_instance->check_phone_status(); - } + $adapter_instance = new $adapter_classname($phone['adapter_data']); + $new_status = $adapter_instance->check_phone_status(); $status_update = $this->internal_phone->update_status($id, $new_status); } diff --git a/db/migrations/20230317144204_add_reached_limit_phone_status.php b/db/migrations/20230317144204_add_reached_limit_phone_status.php deleted file mode 100644 index 18f43b4..0000000 --- a/db/migrations/20230317144204_add_reached_limit_phone_status.php +++ /dev/null @@ -1,38 +0,0 @@ -table('phone'); - $table->changeColumn('status', 'enum', ['values' => ['available', 'unavailable', 'no_credit', 'limit_reached'], 'default' => 'available']); - $table->save(); - } -} diff --git a/models/Phone.php b/models/Phone.php index 6be3735..41fde4d 100644 --- a/models/Phone.php +++ b/models/Phone.php @@ -17,7 +17,6 @@ namespace models; const STATUS_AVAILABLE = 'available'; const STATUS_UNAVAILABLE = 'unavailable'; const STATUS_NO_CREDIT = 'no_credit'; - const STATUS_LIMIT_REACHED = 'limit_reached'; /** * Return all phones that belongs to active users diff --git a/templates/phone/list.php b/templates/phone/list.php index 20aa0e9..d0b192d 100644 --- a/templates/phone/list.php +++ b/templates/phone/list.php @@ -112,10 +112,6 @@ jQuery(document).ready(function () case 'no_credit': html += ' - Plus de crédit' break; - - case 'limit_reached': - html += ' - Limite RaspiSMS atteinte' - break; } return html