- let sth = dbh#prepare_cached "select email, name
- from users
- where hostid = ? and id <> ? and email_notify
- and email is not null
- and invite is null" in
- sth#execute [`Int hostid; `Int own_userid];
-
- let to_addr = sth#map (function
- | [`String email; `String name] ->
- "\"" ^ name ^ "\" <" ^ email ^ ">"
- | _ -> assert false) in
+ let rows = PGSQL(dbh)
+ "select name, email
+ from users
+ where hostid = $hostid and id <> $own_userid and email_notify
+ and email is not null and invite is null" in
+ let to_addr = List.filter_map (
+ function
+ | (name, Some email) ->
+ Some ("\"" ^ name ^ "\" <" ^ email ^ ">")
+ | (name, None) -> None
+ ) rows in