ensure text and at are string in api to create scheduled

This commit is contained in:
osaajani 2021-10-28 17:38:46 +02:00
parent 87a04742a3
commit 69bf62f115
3 changed files with 66 additions and 1 deletions

View File

@ -1 +1 @@
v3.2.0
v3.2.1

View File

@ -272,6 +272,26 @@ namespace controllers\publics;
return $this->json($return);
}
if (!is_string($at))
{
$return = self::DEFAULT_RETURN;
$return['error'] = self::ERROR_CODES['INVALID_PARAMETER'];
$return['message'] = self::ERROR_MESSAGES['INVALID_PARAMETER'] . ' : at must be a string.';
$this->auto_http_code(false);
return $this->json($return);
}
if (!is_string($text))
{
$return = self::DEFAULT_RETURN;
$return['error'] = self::ERROR_CODES['INVALID_PARAMETER'];
$return['message'] = self::ERROR_MESSAGES['INVALID_PARAMETER'] . ' : text must be a string.';
$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;
@ -282,6 +302,9 @@ namespace controllers\publics;
return $this->json($return);
}
$at = (string) $at;
$text = (string) $text;
if (($this->user['settings']['mms'] ?? false) && $mms)
{
$return = self::DEFAULT_RETURN;

View File

@ -298,6 +298,27 @@ namespace controllers\publics;
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
if (empty($at))
{
\FlashMessage\FlashMessage::push('danger', 'Vous ne pouvez pas créer un Sms sans date.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
if (!is_string($at))
{
\FlashMessage\FlashMessage::push('danger', 'La date doit être valide.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
if (!is_string($text))
{
\FlashMessage\FlashMessage::push('danger', 'Votre message doit être un texte.');
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.');
@ -435,6 +456,27 @@ namespace controllers\publics;
continue;
}
if (empty($at))
{
\FlashMessage\FlashMessage::push('danger', 'Vous ne pouvez pas créer un Sms sans date.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
if (!is_string($at))
{
\FlashMessage\FlashMessage::push('danger', 'La date doit être valide.');
return $this->redirect(\descartes\Router::url('Scheduled', 'add'));
}
if (!is_string($text))
{
\FlashMessage\FlashMessage::push('danger', 'Votre message doit être un texte.');
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;