(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: invite_user.ml,v 1.2 2004/10/23 15:00:15 rich Exp $
+ * $Id: invite_user.ml,v 1.3 2004/10/30 10:16:10 rich Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
return ()
);
- let userid, username = match user with
- User (userid, username, _) -> userid, username
+ let userid, username, email = match user with
+ User (userid, username, _, prefs) -> userid, username, prefs.email
| _ -> assert false in
let subject = username ^ " has invited you to join " ^ hostname in
- (* Get user's own email address, which will be the return address
- * for the email.
- *)
- let sth = dbh#prepare_cached "select email from users
- where hostid = ? and id = ?" in
- sth#execute [`Int hostid; `Int userid];
-
+ (* Get a suitable return address for the email. *)
let from =
- match sth#fetch1 () with
- [ `String email ] -> email
- | [ `Null ] -> "service@merjis.com"
- | _ -> assert false in
+ match email with
+ | Some email -> email
+ | None -> "service@merjis.com" in
(* Add user accounts for these new users. For users who are already
* registered, we'll send reminder emails.