From 2d07a0d6e67e30dd6610c6bbc18810b27db7f8aa Mon Sep 17 00:00:00 2001 From: andryyy Date: Wed, 16 Jan 2019 19:10:47 +0100 Subject: [PATCH] [Web] Delete index data from Solr when deleting mailbox --- data/web/inc/functions.mailbox.inc.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php index f1ed9a213..d728794bc 100644 --- a/data/web/inc/functions.mailbox.inc.php +++ b/data/web/inc/functions.mailbox.inc.php @@ -3399,6 +3399,25 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) { 'msg' => 'Could not move maildir to garbage collector: variables local_part and/or domain empty' ); } + if (strtolower(getenv('SKIP_SOLR')) == 'n') { + $curl = curl_init(); + curl_setopt($curl, CURLOPT_URL, 'http://solr:8983/solr/dovecot/update?commit=true'); + curl_setopt($curl, CURLOPT_HTTPHEADER,array('Content-Type: text/xml')); + curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl, CURLOPT_POST, 1); + curl_setopt($curl, CURLOPT_POSTFIELDS, 'user:' . $username . ''); + curl_setopt($curl, CURLOPT_TIMEOUT, 30); + $response = curl_exec($curl); + if ($response === false) { + $err = curl_error($curl); + $_SESSION['return'][] = array( + 'type' => 'warning', + 'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr), + 'msg' => 'Could not remove Solr index: ' . print_r($err, true) + ); + } + curl_close($curl); + } $stmt = $pdo->prepare("DELETE FROM `alias` WHERE `goto` = :username"); $stmt->execute(array( ':username' => $username