Removed the logic that attempted to deliver mailing lists not more than once per...
[citadel.git] / citadel / modules / network / serv_netspool.c
index 697ca62c095a844477a4c71402aa8c1ac3f9305e..ab0aa9f9963dd6032d632c6261607f89d953b343 100644 (file)
@@ -293,7 +293,7 @@ void InspectQueuedRoom(SpoolControl **pSC,
        if ( (!HaveSpoolConfig(sc->RNCfg)) || (sc->room.QRhighest <= sc->RNCfg->lastsent) ) 
        {
                // There is nothing to send from this room.
-               syslog(LOG_DEBUG, "Nothing to do for <%s>", room_to_spool->name);
+               MARK_syslog(LOG_DEBUG, "Nothing to do for <%s>", room_to_spool->name);
                FreeRoomNetworkStruct(&sc->RNCfg);
                sc->RNCfg = NULL;
                free(sc);
@@ -325,27 +325,23 @@ void InspectQueuedRoom(SpoolControl **pSC,
 void CalcListID(SpoolControl *sc)
 {
        StrBuf *RoomName;
-       const char *err;
-       int fd;
        struct CitContext *CCC = CC;
-       char filename[PATH_MAX];
 #define MAX_LISTIDLENGTH 150
 
-       assoc_file_name(filename, sizeof filename, &sc->room, ctdl_info_dir);
-       fd = open(filename, 0);
-
-       if (fd > 0) {
-               struct stat stbuf;
-
-               if ((fstat(fd, &stbuf) == 0) &&
-                   (stbuf.st_size > 0))
-               {
-                       sc->RoomInfo = NewStrBufPlain(NULL, stbuf.st_size + 1);
-                       StrBufReadBLOB(sc->RoomInfo, &fd, 0, stbuf.st_size, &err);
-               }
-               close(fd);
+       // Load the room banner as the list description
+       struct CtdlMessage *msg = CtdlFetchMessage(sc->room.msgnum_info, 1, 1);
+        if (msg != NULL) {
+               CC->redirect_buffer = NewStrBufPlain(NULL, SIZ);
+                CtdlOutputPreLoadedMsg(msg, MT_CITADEL, HEADERS_NONE, 0, 0, 0);
+                CM_Free(msg);
+               sc->RoomInfo = CC->redirect_buffer;
+               CC->redirect_buffer = NULL;
+        }
+       else {
+               sc->RoomInfo = NewStrBufPlain(NULL, SIZ);
        }
 
+       // Calculate the List ID
        sc->ListID = NewStrBufPlain(NULL, 1024);
        if (StrLength(sc->RoomInfo) > 0)
        {
@@ -414,7 +410,6 @@ void CalcListID(SpoolControl *sc)
        FreeStrBuf(&RoomName);
 }
 
-static time_t last_digest_delivery = 0;
 
 /*
  * Batch up and send all outbound traffic from the current room
@@ -454,8 +449,7 @@ void network_spoolout_room(SpoolControl *sc)
        }
        else
        {
-               snprintf(buf, sizeof buf, "room_%s@%s",
-                        CCC->room.QRname, CtdlGetConfigStr("c_fqdn"));
+               snprintf(buf, sizeof buf, "room_%s@%s", CCC->room.QRname, CtdlGetConfigStr("c_fqdn"));
        }
 
        for (i=0; buf[i]; ++i) {
@@ -465,41 +459,18 @@ void network_spoolout_room(SpoolControl *sc)
 
 
        /* If we wrote a digest, deliver it and then close it */
-       if (sc->Users[digestrecp] != NULL) {
-               time_t now = time(NULL);
-               time_t secs_today = now % (24 * 60 * 60);
-               long delta = 0;
-
-               if (last_digest_delivery != 0) {
-                       delta = now - last_digest_delivery;
-                       delta = (24 * 60 * 60) - delta;
-               }
-
-               if ((secs_today < 300) && 
-                   (delta < 300))
-               {
-                       if (sc->digestfp == NULL) {
-                               sc->digestfp = create_digest_file(&sc->room, 0);
-                       }
-                       if (sc->digestfp != NULL) {
-                               last_digest_delivery = now;
-                               fprintf(sc->digestfp,
-                                       " -----------------------------------"
-                                       "------------------------------------"
-                                       "-------\n"
-                                       "You are subscribed to the '%s' "
-                                       "list.\n"
-                                       "To post to the list: %s\n",
-                                       CCC->room.QRname, buf
-                                       );
-                               network_deliver_digest(sc);     /* deliver */
-                               remove_digest_file(&sc->room);
-                       }
-               }
-       }
-       if (sc->digestfp != NULL) {
+       if ( (sc->Users[digestrecp] != NULL) && (sc->digestfp != NULL) )
+       {
+               fprintf(sc->digestfp,
+                       " ------------------------------------------------------------------------------\n"
+                       "You are subscribed to the '%s' list.\n"
+                       "To post to the list: %s\n",
+                       CCC->room.QRname, buf
+               );
+               network_deliver_digest(sc);     /* deliver */
                fclose(sc->digestfp);
                sc->digestfp = NULL;
+               remove_digest_file(&sc->room);
        }
 
        /* Now rewrite the netconfig */
@@ -845,11 +816,11 @@ void network_do_spoolin(HashList *working_ignetcfg, HashList *the_netmap, int *n
         */
        if (stat(ctdl_netin_dir, &statbuf)) return;
        if (statbuf.st_mtime == last_spoolin_mtime) {
-               syslog(LOG_DEBUG, "network: nothing in inbound queue");
+               MARKM_syslog(LOG_DEBUG, "network: nothing in inbound queue");
                return;
        }
        last_spoolin_mtime = statbuf.st_mtime;
-       syslog(LOG_DEBUG, "network: processing inbound queue");
+       MARKM_syslog(LOG_DEBUG, "network: processing inbound queue");
 
        /*
         * Ok, there's something interesting in there, so scan it.