From 70216f97b955723b5a8f3b3acb4855088b54b62e Mon Sep 17 00:00:00 2001 From: Wrongecho Date: Wed, 2 Sep 2026 07:45:39 +0000 Subject: [PATCH] Contacts API - Contact must be archived before deletion --- api/v1/contacts/delete.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/v1/contacts/delete.php b/api/v1/contacts/delete.php index f171e1a16..84af06ee0 100644 --- a/api/v1/contacts/delete.php +++ b/api/v1/contacts/delete.php @@ -12,10 +12,10 @@ $contact_id = intval($_POST['contact_id']); $delete_count = false; if (!empty($contact_id)) { - $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT contact_name FROM contacts WHERE contact_id = $contact_id AND contact_client_id = $client_id LIMIT 1")); + $row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT contact_name FROM contacts WHERE contact_id = $contact_id AND contact_client_id = $client_id AND contact_archived_at IS NOT NULL LIMIT 1")); $contact_name = escapeSql($row['contact_name'] ?? ''); - $delete_sql = mysqli_query($mysqli, "DELETE FROM contacts WHERE contact_id = $contact_id AND contact_client_id = $client_id LIMIT 1"); + $delete_sql = mysqli_query($mysqli, "DELETE FROM contacts WHERE contact_id = $contact_id AND contact_client_id = $client_id AND contact_archived_at IS NOT NULL LIMIT 1"); // Check delete & get affected rows if ($delete_sql && !empty($contact_name)) {