Adjust preconditions for attempting a digest delivery.
authorWilfried Goesgens <dothebart@citadel.org>
Wed, 31 Dec 2014 18:41:38 +0000 (19:41 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Wed, 31 Dec 2014 18:41:38 +0000 (19:41 +0100)
citadel/modules/network/netspool.h
citadel/modules/network/serv_netmail.c
citadel/modules/network/serv_netspool.c

index 55454a7fb581206cd7d5b9073ee48b8688c6173e..cd5f6a1c7198022e33e67a9ff59cb25e357bc252 100644 (file)
@@ -36,7 +36,7 @@ struct SpoolControl {
        StrBuf *RoomInfo;
        StrBuf *ListID;
        FILE *digestfp;
-       int newDigest;
+       int haveDigest;
        int num_msgs_spooled;
        long lastsent;
 
index 2782fbf8f23bf60a4b8a08fe98534b5fe362cac7..a1938c64cbcfbe949d31c5c4df14d7bd081a47df 100644 (file)
@@ -185,12 +185,6 @@ void network_deliver_digest(SpoolControl *sc)
        if (sc->Users[digestrecp] == NULL)
                return;
 
-       if (sc->num_msgs_spooled < 1) {
-               fclose(sc->digestfp);
-               sc->digestfp = NULL;
-               return;
-       }
-
        msg = malloc(sizeof(struct CtdlMessage));
        memset(msg, 0, sizeof(struct CtdlMessage));
        msg->cm_magic = CTDLMESSAGE_MAGIC;
@@ -221,11 +215,9 @@ void network_deliver_digest(SpoolControl *sc)
        CM_SetAsField(msg, eMesageText, &pbuf, msglen);
 
        /* Now generate the delivery instructions */
-       if (sc->Users[digestrecp] == NULL)
-               return;
 
        /* Where do we want bounces and other noise to be heard?
-        *Surely not the list members! */
+        * Surely not the list members! */
        snprintf(bounce_to, sizeof bounce_to, "room_aide@%s", config.c_fqdn);
 
        /* Now submit the message */
@@ -254,6 +246,7 @@ void network_process_digest(SpoolControl *sc, struct CtdlMessage *omsg, long *de
 
        msg = CM_Duplicate(omsg);
        if (msg != NULL) {
+               sc->haveDigest = 1;
                fprintf(sc->digestfp,
                        " -----------------------------------"
                        "------------------------------------"
index 15f309972537b2592baac01fdfb072bd4d1a5ea0..500d931bf0c57cce635bb116a0283449fe8956ac 100644 (file)
@@ -357,8 +357,8 @@ void network_spoolout_room(SpoolControl *sc)
        if (sc->Users[digestrecp] != NULL) {
                
                sc->digestfp = create_digest_file(&sc->room);
-               sc->newDigest = ftell(sc->digestfp) > 0;
-               if (sc->newDigest) {
+               sc->haveDigest = ftell(sc->digestfp) > 0;
+               if (!sc->haveDigest) {
                        fprintf(sc->digestfp, "Content-type: text/plain\n\n");
                }
        }
@@ -404,7 +404,8 @@ void network_spoolout_room(SpoolControl *sc)
                        delta = (24 * 60 * 60) - delta;
                }
 
-               if ((secs_today < 300) && 
+               if (sc->haveDigest     &&
+                   (secs_today < 300) && 
                    (delta < 300) )
                {
                        last_digest_delivery = now;