summaryrefslogtreecommitdiff
path: root/hosts/surtr
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-12-16 20:29:28 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2022-12-16 20:29:28 +0100
commit6f49d8632e6ceccb0399764e7da86cc4cba9ab04 (patch)
tree39a1e15181139cc9b9cdbacdc6362c743be4753d /hosts/surtr
parentbbb5a2502ad108186c9257c5fa420a4965059043 (diff)
downloadnixos-6f49d8632e6ceccb0399764e7da86cc4cba9ab04.tar
nixos-6f49d8632e6ceccb0399764e7da86cc4cba9ab04.tar.gz
nixos-6f49d8632e6ceccb0399764e7da86cc4cba9ab04.tar.bz2
nixos-6f49d8632e6ceccb0399764e7da86cc4cba9ab04.tar.xz
nixos-6f49d8632e6ceccb0399764e7da86cc4cba9ab04.zip
spm: list/get/patch mailbox mappings
Diffstat (limited to 'hosts/surtr')
-rw-r--r--hosts/surtr/postgresql/default.nix15
1 files changed, 15 insertions, 0 deletions
diff --git a/hosts/surtr/postgresql/default.nix b/hosts/surtr/postgresql/default.nix
index 9cf494ae..907c652d 100644
--- a/hosts/surtr/postgresql/default.nix
+++ b/hosts/surtr/postgresql/default.nix
@@ -220,6 +220,21 @@ in {
220 ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO "postfix-ccert-sender-policy"; 220 ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO "postfix-ccert-sender-policy";
221 GRANT SELECT ON ALL TABLES IN SCHEMA public TO "postfix-ccert-sender-policy"; 221 GRANT SELECT ON ALL TABLES IN SCHEMA public TO "postfix-ccert-sender-policy";
222 COMMIT; 222 COMMIT;
223
224 BEGIN;
225 SELECT _v.register_patch('008-mailbox-mapping-claim', ARRAY['000-base', '002-citext', '003-extensions'], null);
226 ALTER TABLE mailbox_mapping DROP CONSTRAINT mailbox_mapping_extension_check;
227 ALTER TABLE mailbox_mapping ADD CONSTRAINT mailbox_mapping_extension_check CHECK (CASE WHEN extension IS NOT NULL THEN extension NOT LIKE '%+%' AND extension <> ''' AND local IS DISTINCT FROM ''' ELSE true END);
228
229 ALTER TABLE mailbox_mapping DROP CONSTRAINT local_domain_unique;
230 ALTER TABLE mailbox_mapping ADD CONSTRAINT local_domain_unique UNIQUE (local, domain) WHERE extension IS null;
231
232 ALTER TABLE mailbox_mapping ADD CONSTRAINT local_extension_domain_unique UNIQUE (local, extension, domain);
233
234 ALTER TABLE mailbox_mapping ADD COLUMN reject bool NOT NULL DEFAULT false;
235
236 CREATE OR REPLACE VIEW virtual_mailbox_access (lookup, action) AS SELECT (CASE WHEN local IS NULL THEN ''' ELSE local END) || (CASE WHEN extension IS NULL THEN ''' ELSE '+' || extension END) || '@' || domain AS lookup, CASE WHEN mailbox IS NULL OR reject THEN 'REJECT' ELSE 'DUNNO' END AS action FROM mailbox_mapping;
237 COMMIT;
223 ''} 238 ''}
224 239
225 psql etebase postgres -eXf ${pkgs.writeText "etebase.sql" '' 240 psql etebase postgres -eXf ${pkgs.writeText "etebase.sql" ''