Commit | Line | Data |
---|---|---|
2e96b9d4 AC |
1 | (* HCoop Domtool (http://hcoop.sourceforge.net/) |
2 | * Copyright (c) 2006, Adam Chlipala | |
ebb51f80 | 3 | * Copyright (c) 2014 Clinton Ebadi <clinton@unknownlamer.org> |
2e96b9d4 AC |
4 | * |
5 | * This program is free software; you can redistribute it and/or | |
6 | * modify it under the terms of the GNU General Public License | |
7 | * as published by the Free Software Foundation; either version 2 | |
8 | * of the License, or (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
18 | *) | |
19 | ||
20 | (* Setting SpamAssassin filtering preferences *) | |
21 | ||
22 | structure SetSA :> SET_SA = struct | |
23 | ||
ebb51f80 CE |
24 | open MsgTypes |
25 | ||
2e96b9d4 AC |
26 | datatype address = |
27 | User of string | |
28 | | Email of string | |
29 | ||
30 | fun address (User s) = s ^ "@localhost" | |
31 | | address (Email s) = s | |
32 | ||
ebb51f80 | 33 | fun file addr = OS.Path.joinDirFile {dir = Config.SpamAssassin.addrsDb, |
2e96b9d4 AC |
34 | file = address addr} |
35 | ||
36 | fun query addr = Posix.FileSys.access (file addr, []) | |
37 | ||
38 | fun set (addr, setting) = | |
39 | if setting then | |
40 | TextIO.closeOut (TextIO.openAppend (file addr)) | |
41 | else | |
42 | OS.FileSys.remove (file addr) | |
43 | ||
ebb51f80 CE |
44 | fun rebuild () = |
45 | let | |
46 | fun doNode (site, ok) = | |
47 | (print ("New spamassassin data for node " ^ site ^ "\n"); | |
48 | Connect.commandWorker (Domain.get_context (), site, MsgSaChanged)) | |
49 | in | |
97b4d188 | 50 | foldl doNode true (Config.mailNodes_all @ Config.mailNodes_admin) |
ebb51f80 CE |
51 | end |
52 | ||
2e96b9d4 | 53 | end |