From af64723ed1c5d0e57e67144f49663efa2a54b87a Mon Sep 17 00:00:00 2001 From: Christian Haschek Date: Wed, 9 Feb 2022 00:38:45 +0100 Subject: [PATCH] moved deleting of emails to core --- web/api.php | 8 ++------ web/inc/core.php | 9 +++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/web/api.php b/web/api.php index e9d9f17..0de20b0 100644 --- a/web/api.php +++ b/web/api.php @@ -41,13 +41,9 @@ switch($action) $o = array('status'=>'err','reason'=>'Invalid Email ID'); else { - if(unlink($dir.DS.$id.'.json')) - { - $attachments = listAttachmentsOfMailID($email,$id); - foreach($attachments as $attachment) - unlink($dir.DS.'attachments'.DS.$attachment); + + if(deleteEmail($email,$id)) $o = array('status'=>'ok'); - } else $o = array('status'=>'err','reason'=>'Could not delete email. Permission problem?'); } diff --git a/web/inc/core.php b/web/inc/core.php index 1029458..814f4d4 100644 --- a/web/inc/core.php +++ b/web/inc/core.php @@ -87,6 +87,15 @@ function listAttachmentsOfMailID($email,$id) return $o; } +function deleteEmail($email,$id) +{ + $dir = getDirForEmail($email); + $attachments = listAttachmentsOfMailID($email,$id); + foreach($attachments as $attachment) + unlink($dir.DS.'attachments'.DS.$attachment); + unlink($dir.DS.$id.'.json'); +} + function loadSettings() {