NobGit
public nobgit read

NobMail

Based on mailcow: dockerized

Languages

Repository composition by tracked source files.

PHP
PHP 49% JavaScript 35% HTML 9% CSS 4% Shell 2% Python 1% Lua 0% Perl 0% Ruby 0% SCSS 0%
Create file Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git

Commit

[Web] add error handling for get_acl call

d21c1bfa
FreddleSpl0it <[email protected]> 1 year, 11 months ago
data/web/inc/functions.mailbox.inc.php | 35 +++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

Diff

diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php
index 6c24c13f..9a1ae577 100644
--- a/data/web/inc/functions.mailbox.inc.php
+++ b/data/web/inc/functions.mailbox.inc.php
@@ -3248,22 +3248,31 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
           }
 
           // get imap acls
-          $exec_fields = array(
-            'cmd' => 'doveadm',
-            'task' => 'get_acl',
-            'id' => $old_username
-          );
-          $imap_acls = json_decode(docker('post', 'dovecot-mailcow', 'exec', $exec_fields), true);
-          // delete imap acls
-          foreach ($imap_acls as $imap_acl) {
+          try {
             $exec_fields = array(
               'cmd' => 'doveadm',
-              'task' => 'delete_acl',
-              'user' => $imap_acl['user'],
-              'mailbox' => $imap_acl['mailbox'],
-              'id' => $imap_acl['id']
+              'task' => 'get_acl',
+              'id' => $old_username
             );
-            docker('post', 'dovecot-mailcow', 'exec', $exec_fields);
+            $imap_acls = json_decode(docker('post', 'dovecot-mailcow', 'exec', $exec_fields), true);
+            // delete imap acls
+            foreach ($imap_acls as $imap_acl) {
+              $exec_fields = array(
+                'cmd' => 'doveadm',
+                'task' => 'delete_acl',
+                'user' => $imap_acl['user'],
+                'mailbox' => $imap_acl['mailbox'],
+                'id' => $imap_acl['id']
+              );
+              docker('post', 'dovecot-mailcow', 'exec', $exec_fields);
+            }
+          } catch (Exception $e) {
+            $_SESSION['return'][] = array(
+              'type' => 'danger',
+              'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
+              'msg' => $e->getMessage()
+            );
+            return false;
           }
 
           // rename username in sql