git.annexia.org
/
cocanwiki.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Split the 'page' template into two halves to enable pipelining. The
[cocanwiki.git]
/
scripts
/
mail_import.ml
diff --git
a/scripts/mail_import.ml
b/scripts/mail_import.ml
index
19b1073
..
9e30fc9
100644
(file)
--- 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 <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: mail_import.ml,v 1.
3 2004/10/11 16:07:25
rich Exp $
+ * $Id: mail_import.ml,v 1.
6 2004/10/20 15:17:18
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
*
* 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_date
open Cocanwiki_strings
open Cocanwiki_pages
+open Cocanwiki_mail
let irt_re = Pcre.regexp "<.*?>"
let ws_re = Pcre.regexp "\\s+"
let irt_re = Pcre.regexp "<.*?>"
let ws_re = Pcre.regexp "\\s+"
@@
-57,8
+58,6
@@
let run r (q : cgi) (dbh : Dbi.connection) hostid _ user =
upload.upload_value
with
Not_found ->
upload.upload_value
with
Not_found ->
- (* Force an error status which a script can detect. *)
- Request.set_status r cHTTP_BAD_REQUEST;
error ~back_button:true ~title:"No message"
q "No message was uploaded.";
return () in
error ~back_button:true ~title:"No message"
q "No message was uploaded.";
return () in
@@
-86,12
+85,15
@@
let run r (q : cgi) (dbh : Dbi.connection) hostid _ user =
* cannot thread it, so give up.
*)
if date = "" || inet_message_id = "" then (
* cannot thread it, so give up.
*)
if date = "" || inet_message_id = "" then (
- Request.set_status r cHTTP_BAD_REQUEST;
error ~back_button:true ~title:"Headers missing"
q "Date or Message-ID header missing. Cannot handle this message. ";
return ()
);
error ~back_button:true ~title:"Headers missing"
q "Date or Message-ID header missing. Cannot handle this message. ";
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
(* Parse the date field. *)
let date, time =
try
@@
-190,7
+192,10
@@
let run r (q : cgi) (dbh : Dbi.connection) hostid _ user =
*)
msgid in
*)
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. *)
let title = sprintf "Mail/%s (%d)" subject msgid in
(* Choose a suitable URL. *)
@@
-315,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
loop line links) lines in
let lines = List.map trim lines in
- let lines =
- List.map (fun line -> if line <> "" then line ^ " <br>" else "")
- lines in
+ let lines = List.map (fun line -> line ^ "<br>") lines in
String.concat "\n" lines
in
String.concat "\n" lines
in
@@
-351,6
+354,10
@@
let run r (q : cgi) (dbh : Dbi.connection) hostid _ user =
*)
save_page dbh hostid ~user ~r model;
*)
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 ();
(* Commit to the database. *)
dbh#commit ();