<?php
include_once __DIR__ . '/../secrets.php';
include '../db_connect.php';

$id = $_POST['request_id'];
$key  = $_POST['key'];

$security_key = decrypData($key);

if ($security_key === false) {
    echo 'Invalid encryption data';
    exit;
}

if ($security_key == SECURITY_KEY_PLAIN) {
    
    $con = dbConnect();
    
$sql = "UPDATE friends_request
        SET status='rejected'
        WHERE id='$id'";

if(mysqli_query($con, $sql)){
    echo "rejected";
} else {
    echo "error";
}

}

?>
