Skip to content

Commit

Permalink
v2.1.1 (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
bfren authored Sep 21, 2024
2 parents 1f94201 + 4e1fc49 commit 2914fba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.1.1
19 changes: 17 additions & 2 deletions src/api/safeguarding/safeguarding.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,25 @@ private static function execute(Baserow $table, array $row): Json
return new Json($result->content);
} else {
_l("Unable to execute Baserow insert: %s.", json_encode($result->content));
return new Json(array("error" => $result->content, "data" => $row), $result->status);
return self::error(array("error" => $result->content, "data" => $row), $result->status);
}
}

/**
* Returns an error as HTTP 200 if always_200 is set to true - to support Forminator WP Plugin.
*
* @param mixed $model Error model.
* @param int $status Status to return if always_200 is false.
* @return Json Json response to return to the client.
*/
private static function error(mixed $model, int $status) : Json
{
return match (Request::$get->bool("always_200")) {
true => new Json($model),
false => new Json($model, $status)
};
}

/**
* Retrieve JSON request object and post it to the Safeguarding Concern table in Baserow.
*
Expand All @@ -57,7 +72,7 @@ public function concern_post(): Json
if (Request::$get->bool("bypass_checks")) {
$dt = DateTime::now();
} else {
return new Json(array("error" => sprintf("Unable to parse date: %s.", $dt_string)), 400);
return self::error(array("error" => sprintf("Unable to parse date: %s.", $dt_string)), 400);
}
}

Expand Down

0 comments on commit 2914fba

Please sign in to comment.