fix: enable sending test notifications with an empty db
This commit is contained in:
+1
-16
@@ -197,24 +197,10 @@ if(isset($_GET["latitude"])){
|
||||
}
|
||||
|
||||
if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") {
|
||||
$db = new SQLite3($home."/BirdNET-Pi/scripts/birds.db", SQLITE3_OPEN_READONLY);
|
||||
$db->busyTimeout(1000);
|
||||
$statement0 = $db->prepare('SELECT * FROM detections ORDER BY Date DESC, Time DESC LIMIT 1');
|
||||
$result0 = $statement0->execute();
|
||||
while($todaytable=$result0->fetchArray(SQLITE3_ASSOC))
|
||||
{
|
||||
$detection = json_encode($todaytable);
|
||||
}
|
||||
|
||||
$conf = $_GET['apprise_config'];
|
||||
$title = $_GET['apprise_notification_title'];
|
||||
$body = $_GET['apprise_notification_body'];
|
||||
|
||||
$temp_det = tmpfile();
|
||||
$t_det_path = stream_get_meta_data($temp_det)['uri'];
|
||||
chmod($t_det_path, 0644);
|
||||
fwrite($temp_det, $detection);
|
||||
|
||||
$temp_conf = tmpfile();
|
||||
$t_conf_path = stream_get_meta_data($temp_conf)['uri'];
|
||||
chmod($t_conf_path, 0644);
|
||||
@@ -225,10 +211,9 @@ if(isset($_GET['sendtest']) && $_GET['sendtest'] == "true") {
|
||||
chmod($t_body_path, 0644);
|
||||
fwrite($temp_body, $body);
|
||||
|
||||
$cmd = "sudo -u $user $home/BirdNET-Pi/birdnet/bin/python3 $home/BirdNET-Pi/scripts/send_test_notification.py --body $t_body_path --config $t_conf_path --title '" . escapeshellcmd($title) . "' --detection $t_det_path 2>&1";
|
||||
$cmd = "sudo -u $user $home/BirdNET-Pi/birdnet/bin/python3 $home/BirdNET-Pi/scripts/send_test_notification.py --body $t_body_path --config $t_conf_path --title '" . escapeshellcmd($title) . "' 2>&1";
|
||||
$ret = shell_exec($cmd);
|
||||
echo "<pre class=\"bash\">".$ret."</pre>";
|
||||
fclose($temp_det);
|
||||
fclose($temp_conf);
|
||||
fclose($temp_body);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user