<?php
namespace ONLINE_ADAv4;

use ONLINE_ADAv4\Helper;

add_action("wp_ajax_" . __NAMESPACE__ . "/save_false_positive", function(){
    if(!isset($_POST["scan_id"]) || !isset($_POST["issue_id"])){ 
		wp_send_json(["status" => "failed", "msg" => "Did not receive the scan ID or the issue ID"], 418);
	}

	$res = Helper::save_false_positive($_POST["scan_id"], $_POST["issue_id"]);
	$res["false_positives"] = Helper::get_false_positives($_POST["scan_id"]);
	if($res["status"] == "success"){
		wp_send_json($res, 200);
	}else{
		wp_send_json($res, 418);
	}
});

add_action("wp_ajax_" . __NAMESPACE__ . "/unmark_false_positive", function(){
    if(!isset($_POST["scan_id"]) || !isset($_POST["issue_id"])){ 
		wp_send_json(["status" => "failed", "msg" => "Did not receive the scan ID or the issue ID"], 418);
	}

	$res = Helper::delete_false_positive($_POST["scan_id"], $_POST["issue_id"]);
	$res["false_positives"] = Helper::get_false_positives($_POST["scan_id"]);
	if($res["status"] == "success"){
		wp_send_json($res, 200);
	}else{
		wp_send_json($res, 418);
	}
});