]> code.citadel.org Git - citadel.git/commitdiff
MailQ: remember & display the room for mailingilst Queue-Entries
authorWilfried Goesgens <dothebart@citadel.org>
Sat, 25 Feb 2012 16:23:31 +0000 (17:23 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Sat, 25 Feb 2012 16:23:31 +0000 (17:23 +0100)
citadel/modules/network/netmail.h
citadel/modules/network/serv_netmail.c
citadel/modules/smtp/serv_smtpqueue.c
citadel/modules/smtp/smtpqueue.h
citadel/msgbase.c
citadel/msgbase.h
citadel/techdoc/delivery-list.txt
webcit/smtpqueue.c
webcit/static/t/view_mailq/message.html

index d2bd14153aadb36fecc169b7c4694533ca940504..c324f43445d8ea7a3111fac1e8141893d65ddfc4 100644 (file)
@@ -1,3 +1,2 @@
 void network_deliver_digest(SpoolControl *sc);
 void network_deliver_digest(SpoolControl *sc);
-void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc);
 void network_spool_msg(long msgnum, void *userdata);
 void network_spool_msg(long msgnum, void *userdata);
index 709877a64a6454cc74530d6f5dcde76942a36f9f..7dcda8db61a9c01044032541599dfedb0dbe9bc1 100644 (file)
@@ -203,7 +203,7 @@ void network_deliver_digest(SpoolControl *sc) {
 /*
  * Deliver list messages to everyone on the list ... efficiently
  */
 /*
  * Deliver list messages to everyone on the list ... efficiently
  */
-void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc) {
+void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc, const char *RoomName) {
        char *recps = NULL;
        size_t recps_len = SIZ;
        struct recptypes *valid;
        char *recps = NULL;
        size_t recps_len = SIZ;
        struct recptypes *valid;
@@ -251,6 +251,7 @@ void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc) {
        if (valid != NULL) {
                valid->bounce_to = strdup(bounce_to);
                valid->envelope_from = strdup(bounce_to);
        if (valid != NULL) {
                valid->bounce_to = strdup(bounce_to);
                valid->envelope_from = strdup(bounce_to);
+               valid->sending_room = strdup(RoomName);
                CtdlSubmitMsg(msg, valid, NULL, 0);
                free_recipients(valid);
        }
                CtdlSubmitMsg(msg, valid, NULL, 0);
                free_recipients(valid);
        }
@@ -390,7 +391,7 @@ void network_spool_msg(long msgnum,
                        }
 
                        /* Handle delivery */
                        }
 
                        /* Handle delivery */
-                       network_deliver_list(msg, sc);
+                       network_deliver_list(msg, sc, CC->room.QRname);
                        CtdlFreeMessage(msg);
                }
        }
                        CtdlFreeMessage(msg);
                }
        }
index 2d406f2e348f71b8e84c113f56ccb80e15e50eb1..c4b46142a250eef6e7653c256bf0b4d9117ecd9a 100644 (file)
@@ -170,6 +170,7 @@ void FreeQueItem(OneQueItem **Item)
        DeleteHash(&(*Item)->MailQEntries);
        FreeStrBuf(&(*Item)->EnvelopeFrom);
        FreeStrBuf(&(*Item)->BounceTo);
        DeleteHash(&(*Item)->MailQEntries);
        FreeStrBuf(&(*Item)->EnvelopeFrom);
        FreeStrBuf(&(*Item)->BounceTo);
+       FreeStrBuf(&(*Item)->SenderRoom);
        FreeURL(&(*Item)->URL);
        free(*Item);
        Item = NULL;
        FreeURL(&(*Item)->URL);
        free(*Item);
        Item = NULL;
@@ -296,6 +297,11 @@ StrBuf *SerializeQueueItem(OneQueItem *MyQItem)
                StrBufAppendBuf(QMessage, MyQItem->EnvelopeFrom, 0);
        }
 
                StrBufAppendBuf(QMessage, MyQItem->EnvelopeFrom, 0);
        }
 
+       if (StrLength(MyQItem->SenderRoom) > 0) {
+               StrBufAppendBufPlain(QMessage, HKEY("\nsource_room|"), 0);
+               StrBufAppendBuf(QMessage, MyQItem->SenderRoom, 0);
+       }
+
        StrBufAppendBufPlain(QMessage, HKEY("\nretry|"), 0);
        StrBufAppendPrintf(QMessage, "%ld",
                           MyQItem->Retry);
        StrBufAppendBufPlain(QMessage, HKEY("\nretry|"), 0);
        StrBufAppendPrintf(QMessage, "%ld",
                           MyQItem->Retry);
@@ -364,6 +370,13 @@ void QItem_Handle_BounceTo(OneQueItem *Item, StrBuf *Line, const char **Pos)
        StrBufExtract_NextToken(Item->BounceTo, Line, Pos, '|');
 }
 
        StrBufExtract_NextToken(Item->BounceTo, Line, Pos, '|');
 }
 
+void QItem_Handle_SenderRoom(OneQueItem *Item, StrBuf *Line, const char **Pos)
+{
+       if (Item->SenderRoom == NULL)
+               Item->SenderRoom = NewStrBufPlain(NULL, StrLength(Line));
+       StrBufExtract_NextToken(Item->SenderRoom, Line, Pos, '|');
+}
+
 void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
 {
        if (Item->Current == NULL)
 void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
 {
        if (Item->Current == NULL)
@@ -555,6 +568,17 @@ void smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt)
        StrBufAppendBuf(BounceMB, Msg, 0);
        FreeStrBuf(&Msg);
 
        StrBufAppendBuf(BounceMB, Msg, 0);
        FreeStrBuf(&Msg);
 
+       if (StrLength(MyQItem->SenderRoom) > 0)
+       {
+               StrBufAppendBufPlain(
+                       BounceMB,
+                       HKEY("The message was originaly posted in: "), 0);
+               StrBufAppendBuf(BounceMB, MyQItem->SenderRoom, 0);
+               StrBufAppendBufPlain(
+                       BounceMB,
+                       HKEY("\n"), 0);
+       }
+
        /* Attach the original message */
        StrBufAppendBufPlain(BounceMB, HKEY("--"), 0);
        StrBufAppendBuf(BounceMB, boundary, 0);
        /* Attach the original message */
        StrBufAppendBufPlain(BounceMB, HKEY("--"), 0);
        StrBufAppendBuf(BounceMB, boundary, 0);
@@ -1033,8 +1057,8 @@ CTDL_MODULE_INIT(smtp_queu)
                Put(QItemHandlers, HKEY("attempted"), QItem_Handle_Attempted, reference_free_handler);
                Put(QItemHandlers, HKEY("remote"), QItem_Handle_Recipient, reference_free_handler);
                Put(QItemHandlers, HKEY("bounceto"), QItem_Handle_BounceTo, reference_free_handler);
                Put(QItemHandlers, HKEY("attempted"), QItem_Handle_Attempted, reference_free_handler);
                Put(QItemHandlers, HKEY("remote"), QItem_Handle_Recipient, reference_free_handler);
                Put(QItemHandlers, HKEY("bounceto"), QItem_Handle_BounceTo, reference_free_handler);
+               Put(QItemHandlers, HKEY("source_room"), QItem_Handle_SenderRoom, reference_free_handler);
                Put(QItemHandlers, HKEY("submitted"), QItem_Handle_Submitted, reference_free_handler);
                Put(QItemHandlers, HKEY("submitted"), QItem_Handle_Submitted, reference_free_handler);
-
                smtp_init_spoolout();
 
                CtdlRegisterCleanupHook(smtp_evq_cleanup);
                smtp_init_spoolout();
 
                CtdlRegisterCleanupHook(smtp_evq_cleanup);
index 97b76e7901518838e9f00b6294a030c940bca048..1b834f9b122a896842501aa78300870b90d7dd16 100644 (file)
@@ -30,6 +30,7 @@ typedef struct _mailq_entry {
        /**<
         * 0 = No delivery has yet been attempted
         * 2 = Delivery was successful
        /**<
         * 0 = No delivery has yet been attempted
         * 2 = Delivery was successful
+        * 3 = Transient error like connection problem. Try next remote if available.
         * 4 = A transient error was experienced ... try again later
         * 5 = Delivery to this address failed permanently.  The error message
         *     should be placed in the fourth field so that a bounce message may
         * 4 = A transient error was experienced ... try again later
         * 5 = Delivery to this address failed permanently.  The error message
         *     should be placed in the fourth field so that a bounce message may
@@ -56,6 +57,7 @@ typedef struct queueitem {
        long ActiveDeliveries;
        StrBuf *EnvelopeFrom;
        StrBuf *BounceTo;
        long ActiveDeliveries;
        StrBuf *EnvelopeFrom;
        StrBuf *BounceTo;
+       StrBuf *SenderRoom;
        ParsedURL *URL;
        ParsedURL *FallBackHost;
 } OneQueItem;
        ParsedURL *URL;
        ParsedURL *FallBackHost;
 } OneQueItem;
index cedd10984727755f5bca5f225c09dab678662102..6551f696a96d7ce81a206f7f7c4b0b75a3f62ad2 100644 (file)
@@ -3027,7 +3027,6 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
        int qualified_for_journaling = 0;
        CitContext *CCC = MyContext();
        char bounce_to[1024] = "";
        int qualified_for_journaling = 0;
        CitContext *CCC = MyContext();
        char bounce_to[1024] = "";
-       size_t tmp = 0;
        int rv = 0;
 
        syslog(LOG_DEBUG, "CtdlSubmitMsg() called\n");
        int rv = 0;
 
        syslog(LOG_DEBUG, "CtdlSubmitMsg() called\n");
@@ -3337,29 +3336,41 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,     /* message to save */
         * contain a recipient.
         */
        if ((recps != NULL) && (recps->num_internet > 0)) {
         * contain a recipient.
         */
        if ((recps != NULL) && (recps->num_internet > 0)) {
+               StrBuf *SpoolMsg = NewStrBuf();
+               long nTokens;
+
                syslog(LOG_DEBUG, "Generating delivery instructions\n");
                syslog(LOG_DEBUG, "Generating delivery instructions\n");
-               instr_alloc = 1024;
-               instr = malloc(instr_alloc);
-               snprintf(instr, instr_alloc,
-                        "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n"
-                        "bounceto|%s\n",
-                        SPOOLMIME, newmsgid, (long)time(NULL),
-                        bounce_to
-                       );
 
 
-               if (recps->envelope_from != NULL) {
-                       tmp = strlen(instr);
-                       snprintf(&instr[tmp], instr_alloc-tmp, "envelope_from|%s\n", recps->envelope_from);
-               }
+               StrBufPrintf(SpoolMsg,
+                            "Content-type: "SPOOLMIME"\n"
+                            "\n"
+                            "msgid|%ld\n"
+                            "submitted|%ld\n"
+                            "bounceto|%s\n",
+                            newmsgid,
+                            (long)time(NULL),
+                            bounce_to);
 
 
-               for (i=0; i<num_tokens(recps->recp_internet, '|'); ++i) {
-                       tmp = strlen(instr);
-                       extract_token(recipient, recps->recp_internet, i, '|', sizeof recipient);
-                       if ((tmp + strlen(recipient) + 32) > instr_alloc) {
-                               instr_alloc = instr_alloc * 2;
-                               instr = realloc(instr, instr_alloc);
+               if (recps->envelope_from != NULL) {
+                       StrBufAppendBufPlain(SpoolMsg, HKEY("envelope_from|"), 0);
+                       StrBufAppendBufPlain(SpoolMsg, recps->envelope_from, -1, 0);
+                       StrBufAppendBufPlain(SpoolMsg, HKEY("\n"), 0);
+               }
+               if (recps->sending_room != NULL) {
+                       StrBufAppendBufPlain(SpoolMsg, HKEY("source_room|"), 0);
+                       StrBufAppendBufPlain(SpoolMsg, recps->sending_room, -1, 0);
+                       StrBufAppendBufPlain(SpoolMsg, HKEY("\n"), 0);
+               }
+
+               nTokens = num_tokens(recps->recp_internet, '|');
+               for (i = 0; i < nTokens; i++) {
+                       long len;
+                       len = extract_token(recipient, recps->recp_internet, i, '|', sizeof recipient);
+                       if (len > 0) {
+                               StrBufAppendBufPlain(SpoolMsg, HKEY("remote|"), 0);
+                               StrBufAppendBufPlain(SpoolMsg, recipient, len, 0);
+                               StrBufAppendBufPlain(SpoolMsg, HKEY("|0||\n"), 0);
                        }
                        }
-                       snprintf(&instr[tmp], instr_alloc - tmp, "remote|%s|0||\n", recipient);
                }
 
                imsg = malloc(sizeof(struct CtdlMessage));
                }
 
                imsg = malloc(sizeof(struct CtdlMessage));
@@ -3370,7 +3381,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
                imsg->cm_fields['U'] = strdup("QMSG");
                imsg->cm_fields['A'] = strdup("Citadel");
                imsg->cm_fields['J'] = strdup("do not journal");
                imsg->cm_fields['U'] = strdup("QMSG");
                imsg->cm_fields['A'] = strdup("Citadel");
                imsg->cm_fields['J'] = strdup("do not journal");
-               imsg->cm_fields['M'] = instr;   /* imsg owns this memory now */
+               imsg->cm_fields['M'] = SmashStrBuf(&SpoolMsg);  /* imsg owns this memory now */
                CtdlSubmitMsg(imsg, NULL, SMTP_SPOOLOUT_ROOM, QP_EADDR);
                CtdlFreeMessage(imsg);
        }
                CtdlSubmitMsg(imsg, NULL, SMTP_SPOOLOUT_ROOM, QP_EADDR);
                CtdlFreeMessage(imsg);
        }
index 37a94c63d16e8a3f564a5aa0c6a6b57bda538ab5..59b02457b7a3b8d45f8a4ab58b679c3e47a81e70 100644 (file)
@@ -75,6 +75,7 @@ struct recptypes {
        char *display_recp;
        char *bounce_to;
        char *envelope_from;
        char *display_recp;
        char *bounce_to;
        char *envelope_from;
+       char *sending_room;
 };
 
 #define RECPTYPES_MAGIC 0xfeeb
 };
 
 #define RECPTYPES_MAGIC 0xfeeb
index f1c2219427e71924e00defac16893176e1da7dee..da2ba524ec40bc134f50d850fe68b76f5d5f7981 100644 (file)
@@ -75,6 +75,15 @@ fails).
     phase of the SMTP transaction.  If an envelope sender is not supplied,
     one is extracted from the message body.
 
     phase of the SMTP transaction.  If an envelope sender is not supplied,
     one is extracted from the message body.
 
+ INSTRUCTION:  source_room
+ SYNTAX:       source_room|Citadel Support
+ DESCRIPTION:
+    when sending mailinglist rooms this contains the source room for displaying
+    and messaging purposes.
+
+
+
+
 -- Once per Remote-part per Queue-Item --
 
  INSTRUCTION:  remote
 -- Once per Remote-part per Queue-Item --
 
  INSTRUCTION:  remote
index 4a30afa45b80dd334864420fed0b3a03b3e9e7ad..f5e3908258f24087fb78449781dd944ac443c87f 100644 (file)
@@ -275,6 +275,7 @@ typedef struct _mailq_entry {
        /**<
         * 0 = No delivery has yet been attempted
         * 2 = Delivery was successful
        /**<
         * 0 = No delivery has yet been attempted
         * 2 = Delivery was successful
+        * 3 = Transient error like connection problem. Try next remote if available.
         * 4 = A transient error was experienced ... try again later
         * 5 = Delivery to this address failed permanently.  The error message
         *     should be placed in the fourth field so that a bounce message may
         * 4 = A transient error was experienced ... try again later
         * 5 = Delivery to this address failed permanently.  The error message
         *     should be placed in the fourth field so that a bounce message may
@@ -301,6 +302,7 @@ typedef struct queueitem {
        long ActiveDeliveries;
        StrBuf *EnvelopeFrom;
        StrBuf *BounceTo;
        long ActiveDeliveries;
        StrBuf *EnvelopeFrom;
        StrBuf *BounceTo;
+       StrBuf *SenderRoom;
        ParsedURL *URL;
        ParsedURL *FallBackHost;
 } OneQueItem;
        ParsedURL *URL;
        ParsedURL *FallBackHost;
 } OneQueItem;
@@ -321,6 +323,7 @@ void FreeQueItem(OneQueItem **Item)
        DeleteHash(&(*Item)->MailQEntries);
        FreeStrBuf(&(*Item)->EnvelopeFrom);
        FreeStrBuf(&(*Item)->BounceTo);
        DeleteHash(&(*Item)->MailQEntries);
        FreeStrBuf(&(*Item)->EnvelopeFrom);
        FreeStrBuf(&(*Item)->BounceTo);
+       FreeStrBuf(&(*Item)->SenderRoom);
        FreeURL(&(*Item)->URL);
        free(*Item);
        Item = NULL;
        FreeURL(&(*Item)->URL);
        free(*Item);
        Item = NULL;
@@ -406,6 +409,18 @@ void tmplput_MailQEnvelopeFrom(StrBuf *Target, WCTemplputParams *TP)
        OneQueItem *Item = (OneQueItem*) CTX;
        StrBufAppendTemplate(Target, TP, Item->EnvelopeFrom, 0);
 }
        OneQueItem *Item = (OneQueItem*) CTX;
        StrBufAppendTemplate(Target, TP, Item->EnvelopeFrom, 0);
 }
+void tmplput_MailQSourceRoom(StrBuf *Target, WCTemplputParams *TP)
+{
+       OneQueItem *Item = (OneQueItem*) CTX;
+       StrBufAppendTemplate(Target, TP, Item->SenderRoom, 0);
+}
+
+int Conditional_MailQ_HaveSourceRoom(StrBuf *Target, WCTemplputParams *TP)
+{
+       OneQueItem *Item = (OneQueItem*) CTX;
+       return StrLength(Item->SenderRoom) > 0;
+}
+
 void tmplput_MailQRetry(StrBuf *Target, WCTemplputParams *TP)
 {
         char datebuf[64];
 void tmplput_MailQRetry(StrBuf *Target, WCTemplputParams *TP)
 {
         char datebuf[64];
@@ -477,6 +492,13 @@ void QItem_Handle_BounceTo(OneQueItem *Item, StrBuf *Line, const char **Pos)
        StrBufExtract_NextToken(Item->BounceTo, Line, Pos, '|');
 }
 
        StrBufExtract_NextToken(Item->BounceTo, Line, Pos, '|');
 }
 
+void QItem_Handle_SenderRoom(OneQueItem *Item, StrBuf *Line, const char **Pos)
+{
+       if (Item->SenderRoom == NULL)
+               Item->SenderRoom = NewStrBufPlain(NULL, StrLength(Line));
+       StrBufExtract_NextToken(Item->SenderRoom, Line, Pos, '|');
+}
+
 void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
 {
        if (Item->Current == NULL)
 void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
 {
        if (Item->Current == NULL)
@@ -626,6 +648,7 @@ InitModule_SMTP_QUEUE
        Put(QItemHandlers, HKEY("attempted"), QItem_Handle_Attempted, reference_free_handler);
        Put(QItemHandlers, HKEY("remote"), QItem_Handle_Recipient, reference_free_handler);
        Put(QItemHandlers, HKEY("bounceto"), QItem_Handle_BounceTo, reference_free_handler);
        Put(QItemHandlers, HKEY("attempted"), QItem_Handle_Attempted, reference_free_handler);
        Put(QItemHandlers, HKEY("remote"), QItem_Handle_Recipient, reference_free_handler);
        Put(QItemHandlers, HKEY("bounceto"), QItem_Handle_BounceTo, reference_free_handler);
+       Put(QItemHandlers, HKEY("source_room"), QItem_Handle_SenderRoom, reference_free_handler);
        Put(QItemHandlers, HKEY("submitted"), QItem_Handle_Submitted, reference_free_handler);
 
        WebcitAddUrlHandler(HKEY("display_smtpqueue"), "", 0, display_smtpqueue, 0);
        Put(QItemHandlers, HKEY("submitted"), QItem_Handle_Submitted, reference_free_handler);
 
        WebcitAddUrlHandler(HKEY("display_smtpqueue"), "", 0, display_smtpqueue, 0);
@@ -639,6 +662,8 @@ InitModule_SMTP_QUEUE
        RegisterNamespace("MAILQ:ATTEMPTED", 0, 0, tmplput_MailQAttempted, NULL, CTX_MAILQITEM);
        RegisterNamespace("MAILQ:SUBMITTED", 0, 0, tmplput_MailQSubmitted, NULL, CTX_MAILQITEM);
        RegisterNamespace("MAILQ:ENVELOPEFROM", 0, 1, tmplput_MailQEnvelopeFrom, NULL, CTX_MAILQITEM);
        RegisterNamespace("MAILQ:ATTEMPTED", 0, 0, tmplput_MailQAttempted, NULL, CTX_MAILQITEM);
        RegisterNamespace("MAILQ:SUBMITTED", 0, 0, tmplput_MailQSubmitted, NULL, CTX_MAILQITEM);
        RegisterNamespace("MAILQ:ENVELOPEFROM", 0, 1, tmplput_MailQEnvelopeFrom, NULL, CTX_MAILQITEM);
+       RegisterNamespace("MAILQ:SRCROOM", 0, 1, tmplput_MailQSourceRoom, NULL, CTX_MAILQITEM);
+       RegisterConditional(HKEY("COND:MAILQ:HAVESRCROOM"), 0, Conditional_MailQ_HaveSourceRoom,  CTX_MAILQITEM);
        RegisterNamespace("MAILQ:RETRY", 0, 0, tmplput_MailQRetry, NULL, CTX_MAILQITEM);
 
        RegisterNamespace("MAILQ:RCPT:ADDR", 0, 1, tmplput_MailQRCPT, NULL, CTX_MAILQ_RCPT);
        RegisterNamespace("MAILQ:RETRY", 0, 0, tmplput_MailQRetry, NULL, CTX_MAILQITEM);
 
        RegisterNamespace("MAILQ:RCPT:ADDR", 0, 1, tmplput_MailQRCPT, NULL, CTX_MAILQ_RCPT);
index a6e972f86c59a009ad365e0808f96b499ca37a84..27ad7d51307e6d832853e560a1af057d536af54a 100644 (file)
@@ -3,7 +3,7 @@
 <?MAILQ:ID></td>
 <td><?MAILQ:SUBMITTED></td>
 <td><?MAILQ:RETRY></td>
 <?MAILQ:ID></td>
 <td><?MAILQ:SUBMITTED></td>
 <td><?MAILQ:RETRY></td>
-<td><?MAILQ:BOUNCETO()><br><?MAILQ:ENVELOPEFROM()></td>
+<td><?MAILQ:BOUNCETO()><br><?MAILQ:ENVELOPEFROM()><?!("COND:MAILQ:HAVESRCROOM", 1)><br><?_("Originaly posted in: ")><?MAILQ:SRCROOM("X")><?!("X", 1)></td>
 
 <td><table class="mailstatus">
 <?ITERATE("MAILQ:RCPT", ="view_mailq_recipient")>
 
 <td><table class="mailstatus">
 <?ITERATE("MAILQ:RCPT", ="view_mailq_recipient")>