Compare commits
2 Commits
48b2ba5684
...
1dd8756d3b
Author | SHA1 | Date |
---|---|---|
osaajani | 1dd8756d3b | |
osaajani | e2bb00cc0c |
|
@ -274,11 +274,11 @@ namespace controllers\internals;
|
||||||
/**
|
/**
|
||||||
* Get all messages to send and the number to use to send theme.
|
* Get all messages to send and the number to use to send theme.
|
||||||
*
|
*
|
||||||
* @return array : [['id_scheduled', 'text', 'id_phone', 'destination', 'flash', 'mms', 'medias'], ...]
|
* @return array : List of smss to send at this time per scheduled id ['1' => [['id_scheduled', 'text', 'id_phone', 'destination', 'flash', 'mms', 'medias'], ...], ...]
|
||||||
*/
|
*/
|
||||||
public function get_smss_to_send()
|
public function get_smss_to_send()
|
||||||
{
|
{
|
||||||
$smss_to_send = [];
|
$smss_to_send_per_scheduled = [];
|
||||||
|
|
||||||
$internal_templating = new \controllers\internals\Templating();
|
$internal_templating = new \controllers\internals\Templating();
|
||||||
$internal_setting = new \controllers\internals\Setting($this->bdd);
|
$internal_setting = new \controllers\internals\Setting($this->bdd);
|
||||||
|
@ -297,6 +297,8 @@ namespace controllers\internals;
|
||||||
$scheduleds = $this->get_model()->gets_before_date($now);
|
$scheduleds = $this->get_model()->gets_before_date($now);
|
||||||
foreach ($scheduleds as $scheduled)
|
foreach ($scheduleds as $scheduled)
|
||||||
{
|
{
|
||||||
|
$smss_to_send_per_scheduled[$scheduled['id']] = [];
|
||||||
|
|
||||||
if (!isset($users_settings[$scheduled['id_user']]))
|
if (!isset($users_settings[$scheduled['id_user']]))
|
||||||
{
|
{
|
||||||
$users_settings[$scheduled['id_user']] = [];
|
$users_settings[$scheduled['id_user']] = [];
|
||||||
|
@ -328,6 +330,7 @@ namespace controllers\internals;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add medias to mms
|
//Add medias to mms
|
||||||
|
$scheduled['medias'] = [];
|
||||||
if ($scheduled['mms'])
|
if ($scheduled['mms'])
|
||||||
{
|
{
|
||||||
$internal_media = new Media($this->bdd);
|
$internal_media = new Media($this->bdd);
|
||||||
|
@ -481,16 +484,16 @@ namespace controllers\internals;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove messages to smsstops numbers
|
//Remove messages to smsstops numbers
|
||||||
if (in_array($message['destination'], $users_smsstops[$scheduled['id_user']]))
|
if (($users_smsstops[$scheduled['id_user']] ?? false) && in_array($message['destination'], $users_smsstops[$scheduled['id_user']]))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$smss_to_send[] = $message;
|
$smss_to_send_per_scheduled[$scheduled['id']][] = $message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $smss_to_send;
|
return $smss_to_send_per_scheduled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -47,8 +47,8 @@ class Sender extends AbstractDaemon
|
||||||
$this->internal_scheduled = new \controllers\internals\Scheduled($this->bdd);
|
$this->internal_scheduled = new \controllers\internals\Scheduled($this->bdd);
|
||||||
|
|
||||||
//Get smss and transmit order to send to appropriate phone daemon
|
//Get smss and transmit order to send to appropriate phone daemon
|
||||||
$smss = $this->internal_scheduled->get_smss_to_send();
|
$smss_per_scheduled = $this->internal_scheduled->get_smss_to_send();
|
||||||
$this->transmit_smss($smss); //Add new queue to array of queues
|
$this->transmit_smss($smss_per_scheduled); //Add new queue to array of queues
|
||||||
|
|
||||||
usleep(0.5 * 1000000);
|
usleep(0.5 * 1000000);
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,11 @@ class Sender extends AbstractDaemon
|
||||||
/**
|
/**
|
||||||
* Function to transfer smss to send to phones daemons.
|
* Function to transfer smss to send to phones daemons.
|
||||||
*
|
*
|
||||||
* @param array $smss : Smss to send
|
* @param array $smss_per_scheduled : Smss to send per scheduled id
|
||||||
*/
|
*/
|
||||||
public function transmit_smss(array $smss): void
|
public function transmit_smss(array $smss_per_scheduled): void
|
||||||
|
{
|
||||||
|
foreach ($smss_per_scheduled as $id_scheduled => $smss)
|
||||||
{
|
{
|
||||||
foreach ($smss as $sms)
|
foreach ($smss as $sms)
|
||||||
{
|
{
|
||||||
|
@ -81,9 +83,11 @@ class Sender extends AbstractDaemon
|
||||||
];
|
];
|
||||||
|
|
||||||
msg_send($this->queues[$queue_id], QUEUE_TYPE_SEND_MSG, $msg);
|
msg_send($this->queues[$queue_id], QUEUE_TYPE_SEND_MSG, $msg);
|
||||||
|
|
||||||
$this->logger->info('Transmit sms send signal to phone ' . $sms['id_phone'] . ' on queue ' . $queue_id . '.');
|
$this->logger->info('Transmit sms send signal to phone ' . $sms['id_phone'] . ' on queue ' . $queue_id . '.');
|
||||||
$this->internal_scheduled->delete($sms['id_scheduled']);
|
}
|
||||||
|
|
||||||
|
$this->logger->info('Scheduled ' . $id_scheduled . ' treated and deleted.');
|
||||||
|
$this->internal_scheduled->delete($id_scheduled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue