X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Fmail_import.ml;h=289e70183c71c3438e4682a41f9e36114e0828a5;hb=e336401181f56f19ec18175d47462e7a5d5f07e2;hp=0cd7a67563c32182ed868302d874e748e2fef63e;hpb=eb57cb1d3f0af6474edcca4fbe5a5be2b6288b6d;p=cocanwiki.git diff --git a/scripts/mail_import.ml b/scripts/mail_import.ml index 0cd7a67..289e701 100644 --- a/scripts/mail_import.ml +++ b/scripts/mail_import.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: mail_import.ml,v 1.4 2004/10/12 10:00:38 rich Exp $ + * $Id: mail_import.ml,v 1.7 2004/12/01 13:55:55 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 @@ -36,6 +36,7 @@ open Cocanwiki_template open Cocanwiki_date open Cocanwiki_strings open Cocanwiki_pages +open Cocanwiki_mail let irt_re = Pcre.regexp "<.*?>" let ws_re = Pcre.regexp "\\s+" @@ -89,6 +90,10 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ user = return () ); + (* Can't handle funny characters in subject lines - remove them. *) + let subject = String.map (fun c -> + if Char.code c < 32 then ' ' else c) subject in + (* Parse the date field. *) let date, time = try @@ -187,7 +192,10 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ user = *) msgid in - (* The message is referred to by a unique title: *) + (* The message is referred to by a unique title. + * NB. Do not change this unique title - it is also used during thread + * indexing. + *) let title = sprintf "Mail/%s (%d)" subject msgid in (* Choose a suitable URL. *) @@ -290,7 +298,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ user = try String.find (String.lowercase str) sub_lc with - String.Invalid_string -> -1 + Invalid_string -> -1 in let rec loop line = function [] -> line @@ -312,9 +320,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ user = loop line links) lines in let lines = List.map trim lines in - let lines = - List.map (fun line -> if line <> "" then line ^ "
" else "") - lines in + let lines = List.map (fun line -> line ^ "
") lines in String.concat "\n" lines in @@ -348,6 +354,10 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ user = *) save_page dbh hostid ~user ~r model; + (* Rebuild threads? *) + if rebuild then + thread_mail dbh hostid ~user ~r date.Dbi.year date.Dbi.month; + (* Commit to the database. *) dbh#commit ();