see to use forcefail

This commit is contained in:
osaajani 2023-02-06 05:05:18 +01:00
parent 47b81c1af3
commit 55fe91619b
1 changed files with 24 additions and 10 deletions

View File

@ -651,13 +651,31 @@ use Monolog\Logger;
}
}
// This should only happen if the user try to send a message without any phone in his account, then we simply ignore.
if (!$random_phone && !$phone_to_use)
$id_phone = $phone_to_use['id'] ?? $random_phone['id'] ?? null;
$forcefail = false;
if (!$id_phone) // This should only happen if the user try to send a message without any phone
{
continue;
$forcefail = true;
}
if ($users_phones[$id_user][$id_phone] ?? false)
{
if ($users_phones[$id_user][$id_phone]['remaining_volume'] <= 0)
{
$forcefail = true;
}
// Consume one sms from remaining volume of phone, dont forget to do the same for the entry in mms phones
$users_phones[$id_user][$id_phone]['remaining_volume'] --;
if ($users_mms_phones[$id_user][$id_phone] ?? false)
{
$users_mms_phones[$id_user][$id_phone] --;
}
}
$id_phone = $phone_to_use['id'] ?? $random_phone['id'];
$sms_per_scheduled[$id_scheduled][] = [
'id_user' => $id_user,
'id_scheduled' => $id_scheduled,
@ -667,14 +685,10 @@ use Monolog\Logger;
'mms' => $scheduled['mms'],
'medias' => $scheduled['medias'],
'text' => $text,
'forcefail' => $forcefail,
];
// Consume one sms from remaining volume of phone, dont forget to do the same for the entry in mms phones
$users_phones[$id_user][$id_phone]['remaining_volume'] --;
if ($users_mms_phones[$id_user][$id_phone] ?? false)
{
$users_mms_phones[$id_user][$id_phone] --;
}
}
}