New action "imap_and_bounce" to simplify e-mail routing logic.
authorBernardo Freitas Paulo da Costa <bernardo.da-costa@m4x.org>
Sat, 30 Oct 2010 23:12:31 +0000 (01:12 +0200)
committerBernardo Freitas Paulo da Costa <bernardo.da-costa@m4x.org>
Sat, 30 Oct 2010 23:12:31 +0000 (01:12 +0200)
Any modifications that would result in a situation like the one here
searched for (that is, one user whose only active redirection is
"imap") must have the action of his imap redirection changed to
"imap_and_bounce".

modified:   01_new_mail.sql
new file:   02_imap_and_bounce.sql

upgrade/1.1.0/01_new_mail.sql
upgrade/1.1.0/02_imap_and_bounce.sql [new file with mode: 0644]

index aa181d5..9184947 100644 (file)
@@ -40,6 +40,7 @@ CREATE TABLE email_redirect_account (
                           'let_spams',
                           'tag_and_drop_spams',
                           'tag_spams',
+                          'imap_and_bounce',
                           'homonym')
                NOT NULL DEFAULT 'default',
        broken        DATE NOT NULL DEFAULT '0000-00-00',
@@ -61,6 +62,7 @@ CREATE TABLE email_redirect_other (
                           'let_spams',
                           'tag_and_drop_spams',
                           'tag_spams',
+                          'imap_and_bounce',
                           'homonym')
                NOT NULL DEFAULT 'default',
        KEY (hrmid),
diff --git a/upgrade/1.1.0/02_imap_and_bounce.sql b/upgrade/1.1.0/02_imap_and_bounce.sql
new file mode 100644 (file)
index 0000000..f1391b1
--- /dev/null
@@ -0,0 +1,10 @@
+UPDATE email_redirect_account AS e,
+       (SELECT IF( SUM(IF(type!='imap',1,0))=0, 'imap_only', 'normal' ) AS status, uid
+            FROM email_redirect_account
+           WHERE flags = 'active'
+        GROUP BY uid) AS sub
+    SET e.action='imap_and_bounce'
+  WHERE sub.status='imap_only'
+    AND sub.uid = e.uid
+    AND type='imap';
+