Manage spamassassin preferences in shared space
[hcoop/domtool2.git] / src / mail / setsa.sml
index ef60dca..32fa0ab 100644 (file)
@@ -1,5 +1,6 @@
 (* HCoop Domtool (http://hcoop.sourceforge.net/)
  * Copyright (c) 2006, Adam Chlipala
+ * Copyright (c) 2014 Clinton Ebadi <clinton@unknownlamer.org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -20,6 +21,8 @@
 
 structure SetSA :> SET_SA = struct
 
+open MsgTypes
+
 datatype address =
         User of string
        | Email of string
@@ -27,7 +30,7 @@ datatype address =
 fun address (User s) = s ^ "@localhost"
   | address (Email s) = s
 
-fun file addr = OS.Path.joinDirFile {dir = Config.SpamAssassin.addrsDir,
+fun file addr = OS.Path.joinDirFile {dir = Config.SpamAssassin.addrsDb,
                                     file = address addr}
 
 fun query addr = Posix.FileSys.access (file addr, [])
@@ -38,4 +41,13 @@ fun set (addr, setting) =
     else
        OS.FileSys.remove (file addr)
 
+fun rebuild () =
+    let
+       fun doNode (site, ok) =
+           (print ("New spamassassin data for node " ^ site ^ "\n");
+            Connect.commandWorker (Domain.get_context (), site, MsgSaChanged))
+    in
+       foldl doNode true Config.mailNodes_all
+    end
+
 end