Compare commits

...

3 Commits

Author SHA1 Message Date
osaajani ea744d31e2 Check phone exists on callback reception 2022-09-26 17:31:32 +02:00
osaajani 5c5571d38a up version 2022-09-26 17:18:15 +02:00
osaajani 11b481aebd add limit check to size of sms 2022-09-26 17:17:41 +02:00
8 changed files with 38 additions and 4 deletions

View File

@ -1 +1 @@
v3.5.0
v3.5.2

View File

@ -252,7 +252,7 @@ class Quota extends StandardController
$renew_interval = $quota['renew_interval'] ?? 'P0D';
$new_start_date = new \DateTime($quota['expiration_date']);
$new_expiration_date = clone $new_start_date;
$new_expiration_date->add(new \DateInterval($quota['renew_interval']));
$new_expiration_date->add(new \DateInterval($renew_interval));
$report = 0;
if ($quota['report_unused'] && $unused_credit > 0)

View File

@ -309,6 +309,16 @@ namespace controllers\publics;
return $this->json($return);
}
if (mb_strlen($text) > \models\Scheduled::SMS_LENGTH_LIMIT)
{
$return = self::DEFAULT_RETURN;
$return['error'] = self::ERROR_CODES['INVALID_PARAMETER'];
$return['message'] = self::ERROR_MESSAGES['INVALID_PARAMETER'] . ' : text must be less than ' . \models\Scheduled::SMS_LENGTH_LIMIT . ' char.';
$this->auto_http_code(false);
return $this->json($return);
}
if (!\controllers\internals\Tool::validate_date($at, 'Y-m-d H:i:s'))
{
$return = self::DEFAULT_RETURN;

View File

@ -155,6 +155,14 @@ use Monolog\Logger;
{
$this->logger->info('Callback reception call with adapter uid : ' . $adapter_uid);
$phone = $this->internal_phone->get_for_user($this->user['id'], $id_phone);
if (!$phone)
{
$this->logger->error('Callback reception use non existing phone : ' . $id_phone);
return false;
}
//Search for an adapter
$find_adapter = false;
$adapters = $this->internal_adapter->list_adapters();

View File

@ -328,6 +328,13 @@ namespace controllers\publics;
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
if (mb_strlen($text) > \models\Scheduled::SMS_LENGTH_LIMIT)
{
\FlashMessage\FlashMessage::push('danger', 'Votre message doit faire moins de ' . \models\Scheduled::SMS_LENGTH_LIMIT . ' caractères.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
if (!\controllers\internals\Tool::validate_date($at, 'Y-m-d H:i:s') && !\controllers\internals\Tool::validate_date($at, 'Y-m-d H:i'))
{
\FlashMessage\FlashMessage::push('danger', 'Vous devez fournir une date valide.');
@ -540,6 +547,13 @@ namespace controllers\publics;
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
if (mb_strlen($text) > \models\Scheduled::SMS_LENGTH_LIMIT)
{
\FlashMessage\FlashMessage::push('danger', 'Votre message doit faire moins de ' . \models\Scheduled::SMS_LENGTH_LIMIT . ' caractères.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
if (!\controllers\internals\Tool::validate_date($at, 'Y-m-d H:i:s') && !\controllers\internals\Tool::validate_date($at, 'Y-m-d H:i'))
{
continue;

View File

@ -13,6 +13,8 @@ namespace models;
class Scheduled extends StandardModel
{
const SMS_LENGTH_LIMIT = 1000;
/**
* Return numbers for a scheduled message.
*

View File

@ -49,7 +49,7 @@
Vous pouvez obtenir une prévisualisation du résultat pour un contact, ainsi qu'une estimation du nombre de crédits qui seront utilisés par SMS, en cliquant sur le boutton <b>"Prévisualiser"</b>.
</p>
<?php } ?>
<textarea name="text" class="form-control" required><?php $this->s($_SESSION['previous_http_post']['text'] ?? '') ?></textarea>
<textarea name="text" class="form-control" required maxlength="<?= \models\Scheduled::SMS_LENGTH_LIMIT; ?>"><?php $this->s($_SESSION['previous_http_post']['text'] ?? '') ?></textarea>
<?php if ($_SESSION['user']['settings']['templating']) { ?>
<div class="scheduled-preview-container">
<label>Prévisualiser pour : </label>

View File

@ -47,7 +47,7 @@
Vous pouvez obtenir une prévisualisation du résultat pour un contact en cliquant sur le boutton <b>"Prévisualiser"</b>.
</p>
<?php } ?>
<textarea name="scheduleds[<?php $this->s($scheduled['id']); ?>][text]" class="form-control" required><?php $this->s($scheduled['text'], true); ?></textarea>
<textarea name="scheduleds[<?php $this->s($scheduled['id']); ?>][text]" class="form-control" required maxlength="<?= \models\Scheduled::SMS_LENGTH_LIMIT; ?>"><?php $this->s($scheduled['text'], true); ?></textarea>
<?php if ($_SESSION['user']['settings']['templating']) { ?>
<div class="scheduled-preview-container">
<label>Prévisualiser pour : </label>