Tweakadeedooda while running through our first real application in a while
[hcoop/zz_old/portal.git] / mailinglist.sml
1 structure MailingList =
2 struct
3
4 structure R = Request(struct
5 val table = "MailingList"
6 val adminGroup = "lists"
7 fun subject list = "Mailman list request: " ^ list
8 val template = "list"
9 val descr = "mailing list"
10
11 fun body (mail, lst) =
12 (Mail.mwrite (mail, "List name: ");
13 Mail.mwrite (mail, lst);
14 Mail.mwrite (mail, "\n"))
15 end)
16 open R
17
18 fun listWebHost name =
19 case String.tokens (fn ch => ch = #"@") name of
20 [user, dom] =>
21 let
22 val mmf = Util.domainDir dom ^ "/.mailman"
23 in
24 if Posix.FileSys.access (mmf, []) then
25 let
26 val inf = TextIO.openIn mmf
27 in
28 (case TextIO.inputLine inf of
29 NONE => (user, dom)
30 | SOME line =>
31 (user, String.substring (line, 0, size line - 1)))
32 before TextIO.closeIn inf
33 end handle _ => (user, dom)
34 else
35 (user, dom)
36 end
37 | _ => raise (Fail "Bad mailing list name")
38
39 end