[Dovecot] Syntax of pattern in map section

Boris da-dovecotlist-15 at abelonline.de
Thu Feb 20 15:59:21 UTC 2014


On Sunday 16 February 2014 17:30:33 da-dovecotlist-15 at abelonline.de wrote:
> I can't seem to find any documentation on the meaning/syntax of the
> "pattern" variable in map sections that are found in
> dovecot-dict-sql.conf.ext for example. I am trying to setup shared folders.

> I need to understand how they work because I can't use the example in
> http://wiki2.dovecot.org/SharedMailboxes/Shared. This is because in my
> PostreSQL table users are not a single column but two columns with the
> local and domain part

I couldn't find anything myself even after skimming through the code so I 
created PostgreSQL rules to circumvent the problem. Here they are in case 
anyone has the same problem. 

This is the view I created for listing shared folders:

CREATE VIEW view_shared_mailboxes AS
    SELECT shared_mailbox_local || '@' || shared_mailbox_domain AS 
"shared_mailbox", shared_to_local || '@' || shared_to_domain AS "shared_to", 1 
AS "dummy"
        FROM shared_mailboxes;

And these are the rules to enable INSERTSs and DELETEs:

CREATE RULE view_shared_mailboxes_insert AS ON INSERT TO view_shared_mailboxes
  DO INSTEAD
  INSERT INTO shared_mailboxes (shared_mailbox_local, shared_mailbox_domain, 
shared_to_local, shared_to_domain)
  VALUES (split_part(NEW.shared_mailbox,'@',1), 
split_part(NEW.shared_mailbox,'@',2), split_part(NEW.shared_to,'@',1), 
split_part(NEW.shared_to,'@',2));

CREATE RULE view_shared_mailboxes_delete AS ON DELETE TO view_shared_mailboxes
  DO INSTEAD
  DELETE FROM shared_mailboxes
  WHERE shared_mailbox_local = split_part(OLD.shared_mailbox,'@',1) AND
	shared_mailbox_domain = split_part(OLD.shared_mailbox,'@',2) AND
	shared_to_local = split_part(OLD.shared_to,'@',1) AND
	shared_to_domain = split_part(OLD.shared_to,'@',2);


More information about the dovecot mailing list