Only start daemons for phones of active users

This commit is contained in:
osaajani 2023-01-31 23:11:25 +01:00
parent ad1f798ae6
commit 1c7a84def0
5 changed files with 40 additions and 3 deletions

View File

@ -1 +1 @@
v3.5.4
v3.5.5

View File

@ -13,7 +13,7 @@
"twilio/sdk": "^6.1",
"symfony/yaml": "^5.0",
"phpmailer/phpmailer": "^6.1",
"ralouphie/mimey": "^2.1",
"xantios/mimey": ">=2.1",
"kreait/firebase-php": "^5.14"
},
"require-dev": {

View File

@ -19,6 +19,18 @@ namespace controllers\internals;
protected $model;
/**
* Return all phones for active users.
*
* @param int $id_user : user id
*
* @return array
*/
public function get_all_for_active_users()
{
return $this->get_model()->get_all_for_active_users();
}
/**
* Return all phones of a user.
*

View File

@ -53,7 +53,7 @@ class Launcher extends AbstractDaemon
$this->start_mailer_daemon();
$phones = $this->internal_phone->get_all();
$phones = $this->internal_phone->get_all_for_active_users();
$this->start_phones_daemons($phones);
sleep(1);

View File

@ -13,6 +13,31 @@ namespace models;
class Phone extends StandardModel
{
/**
* Return all hones that belongs to active users
*
* @return array
*/
public function get_all_for_active_users()
{
$query = '
SELECT phone.*
FROM phone
LEFT JOIN user
ON phone.id_user = user.id
WHERE user.status = :status
';
$params = [
'status' => \models\User::STATUS_ACTIVE,
];
$result = $this->_run_query($query, $params);
return $result;
}
/**
* Return a phone by his name and user.
*