[prev in list] [next in list] [prev in thread] [next in thread] 

List:       listar-support
Subject:    [ESupp] Re: dup-detection bug
From:       Robert Waldner <waldner () waldner ! priv ! at>
Date:       2003-03-18 21:01:56
[Download RAW message or body]


On Tue, 18 Mar 2003 21:26:37 +0100, Robert Waldner writes:
> > I just forgot I was going to do this for you and left the change halfway
> > completed in my sandbox...mea culpa.  I've got a lunch break in about 45
> > minutes, and I could probably do it then. :)

> I'll have a try at it myself, if only to satisfy my curiosity if I 
> _can_ do it ;)

Well, here it is, a shameless fest of copy&paste ;)

In earnest: I don't have a test-box ATM, so I only know it compiles but 
 not if it actually works. If one of the real programmers here says 
 that it looks OKish, I'd be quite grateful and only then go live with it.

cheers,
&rw

.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
--- modules/send_orig/send.c    Tue Mar 18 21:56:03 2003
+++ modules/send/send.c Tue Mar 18 21:50:52 2003
@@ -361,6 +361,55 @@
     return HOOK_RESULT_OK;
 }
 
+/* CHANGES RW */
+HOOK_HANDLER(hook_after_check_messageid)
+{ char buffer[BIG_BUF];
+  FILE *infile, *messagefile;
+  int inbody, gotit;
+
+    if (!LMAPI->get_bool("no-dupes"))
+        return HOOK_RESULT_OK;
+
+
+    /* open the files, fail gracefully if not able to */
+    infile = LMAPI->open_file(LMAPI->get_string("queuefile"), "r");
+    if (infile == NULL) {
+       return HOOK_RESULT_OK;
+    }
+
+    LMAPI->listdir_file(buffer, LMAPI->get_string("list"), "nodupes");
+
+    if ((messagefile = LMAPI->open_exclusive(buffer,"a+")) == NULL) {
+       return HOOK_RESULT_OK;
+    }
+    /* good. all seems to be where we expect it */
+
+    /* now, get the msgid */
+    while(LMAPI->read_file(buffer, sizeof(buffer), infile) && !inbody) {
+     if (!strncasecmp(buffer,"Message-Id:",11)) {
+       gotit = 1;
+       break;
+     }
+     if (buffer[0] == '\n') inbody = 1;
+    }
+
+    if (!gotit) {
+      LMAPI->log_printf(1,"No message ID for message, unable to dupe-check.\n");
+      LMAPI->close_file(messagefile);
+      LMAPI->close_file(infile);
+      return HOOK_RESULT_OK;
+    }
+    /* got it */
+
+    /* write it out */
+    LMAPI->write_file(messagefile,"%s",buffer);
+    LMAPI->close_file(messagefile);
+    LMAPI->close_file(infile);
+    return HOOK_RESULT_OK;
+
+}
+/* /CHANGES RW */
+
 HOOK_HANDLER(hook_presend_check_messageid)
 {
     char buffer[BIG_BUF], buffer2[BIG_BUF];
@@ -432,7 +481,10 @@
 
     if (!docheck) {
       /* We should now be situated at the end of the file */
-       LMAPI->write_file(messagefile,"%s",buffer);
+      /* CHANGES RW: but we won't write the msgid to the file unless
+         the post got successfully handed off to the MTA. */
+       // LMAPI->write_file(messagefile,"%s",buffer);
+       /* /CHANGES RW */
        LMAPI->close_file(messagefile);
        LMAPI->close_file(infile);
        return HOOK_RESULT_OK;
@@ -447,7 +499,10 @@
 
     if (!gotit) {
       /* We should now be situated at the end of the file */
-      LMAPI->write_file(messagefile,"%s",buffer);
+      /* CHANGES RW: but we won't write the msgid to the file unless
+         the post got successfully handed off to the MTA. */
+      // LMAPI->write_file(messagefile,"%s",buffer);
+      /* /CHANGES RW */
       LMAPI->close_file(messagefile);
       LMAPI->close_file(infile);
       return HOOK_RESULT_OK;
.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.

.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
--- modules/send_orig/init.c    Tue Mar 18 21:57:54 2003
+++ modules/send/init.c Tue Mar 18 21:32:04 2003
@@ -94,6 +94,8 @@
     LMAPI->add_hook("TOLIST", 500, hook_tolist_remove_vacationers);
     LMAPI->add_hook("TOLIST", 0, hook_tolist_build_tolist);
 
+    LMAPI->add_hook("AFTER", 999, hook_after_store_messageid);
+
     /* Files */
     LMAPI->add_file("post-password-reject", "post-password-reject-file", "File to \
send to users who try to post to a list with a posting password and who do not \
                include the correct password.");
     LMAPI->add_file("closed", "closed-file", "File to send to users who try to post \
                to a closed for public posts.");
.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.

.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
--- modules/send_orig/send-mod.h        Tue Mar 18 21:58:49 2003
+++ modules/send/send-mod.h     Tue Mar 18 21:52:24 2003
@@ -43,6 +43,8 @@
 extern HOOK_HANDLER(hook_tolist_remove_vacationers);
 extern HOOK_HANDLER(hook_tolist_sort);
 
+extern HOOK_HANDLER(hook_after_store_messageid);
+
 extern CMDARG_HANDLER(cmdarg_private_reply);
 
 #endif /* _SEND_MOD_H */
.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.

-- 
-- Its name is Public Opinion.  It is held in reverence.
-- It settles everything. Some think it is the voice of God.
-- Mark Twain


--
Ecartis Support Mailing List <ecartis-support@ecartis.org>
To unsubscribe:
  <mailto:ecartis-support-request@ecartis.org?Subject=unsubscribe>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic