Rework networker
[citadel.git] / citadel / modules / network / serv_netmail.c
index 709877a64a6454cc74530d6f5dcde76942a36f9f..5b2a02524a5645ed36fa5ea6d2012c47445cfc04 100644 (file)
@@ -2,7 +2,7 @@
  * This module handles shared rooms, inter-Citadel mail, and outbound
  * mailing list processing.
  *
- * Copyright (c) 2000-2011 by the citadel.org team
+ * Copyright (c) 2000-2012 by the citadel.org team
  *
  *  This program is open source software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -203,7 +203,7 @@ void network_deliver_digest(SpoolControl *sc) {
 /*
  * 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;
@@ -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);
+               valid->sending_room = strdup(RoomName);
                CtdlSubmitMsg(msg, valid, NULL, 0);
                free_recipients(valid);
        }
@@ -264,6 +265,7 @@ void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc) {
 void network_spool_msg(long msgnum,
                       void *userdata)
 {
+       StrBuf *Buf = NULL;
        SpoolControl *sc;
        int i;
        char *newpath = NULL;
@@ -390,7 +392,7 @@ void network_spool_msg(long msgnum,
                        }
 
                        /* Handle delivery */
-                       network_deliver_list(msg, sc);
+                       network_deliver_list(msg, sc, CC->room.QRname);
                        CtdlFreeMessage(msg);
                }
        }
@@ -469,9 +471,11 @@ void network_spool_msg(long msgnum,
                                                config.c_nodename)) {
                                        ok_to_participate = 1;
                                }
+
+                               Buf = NewStrBufPlain(msg->cm_fields['N'], -1);
                                if (is_valid_node(NULL,
                                                  NULL,
-                                                 msg->cm_fields['N'],
+                                                 Buf,
                                                  sc->working_ignetcfg,
                                                  sc->the_netmap) == 0)
                                {
@@ -559,11 +563,14 @@ void network_spool_msg(long msgnum,
                    mptr = mptr->next) {
 
                        send = 1;
-
+                       if (Buf == NULL)
+                               Buf = NewStrBufPlain(mptr->remote_nodename, -1);
+                       else
+                               StrBufPlain(Buf, mptr->remote_nodename, -1);
                        /* Check for valid node name */
                        if (is_valid_node(NULL,
                                          NULL,
-                                         mptr->remote_nodename,
+                                         Buf,
                                          sc->working_ignetcfg,
                                          sc->the_netmap) != 0)
                        {
@@ -664,5 +671,5 @@ void network_spool_msg(long msgnum,
        if (delete_after_send) {
                CtdlDeleteMessages(CC->room.QRname, &msgnum, 1, "");
        }
-
+       FreeStrBuf(&Buf);
 }