Compare commits

..

2 Commits

Author SHA1 Message Date
Dirk Heilig af207d8a01 Merge branch 'master' of ssh://git.c3re.de:2222/c3re/mqtt2prom 2024-09-09 19:14:17 +02:00
Dirk Heilig c011f62af5 add validity time parameter 2024-09-09 19:11:35 +02:00
1 changed files with 5 additions and 5 deletions

View File

@ -174,24 +174,24 @@ function precheck(Message $message): bool
}
}
if(!isset($payload["valid_seconds"])){
if (!isset($payload["valid_seconds"])) {
$payload["valid_seconds"] = 60;
}
if(!is_numeric($payload["valid_seconds"])){
if (!is_numeric($payload["valid_seconds"])) {
error("valid_seconds must be a number");
return false;
}
if($payload["valid_seconds"] < 1){
if ($payload["valid_seconds"] < 1) {
error("valid_seconds must be at least 1");
return false;
}
if($payload["valid_seconds"] >60*60*48){
if ($payload["valid_seconds"] > 60 * 60 * 48) {
error("valid_seconds must be at most 48 hours");
return false;
}
foreach (array_keys($payload) as $key) {
if (!in_array($key, ["name", "value", "labels","valid_until"])) {
if (!in_array($key, ["name", "value", "labels", "valid_seconds"])) {
error("Unknown key: $key");
return false;
}