X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fnetwork%2Fserv_netspool.c;h=df1c225dfa0846686281608c87c09c2574842fdf;hb=2e810d36a66a6cc42c345bd924b4e2b7669af8cd;hp=15f309972537b2592baac01fdfb072bd4d1a5ea0;hpb=73bcf6081a14008eb1020126273f133a324bb910;p=citadel.git diff --git a/citadel/modules/network/serv_netspool.c b/citadel/modules/network/serv_netspool.c index 15f309972..df1c225df 100644 --- a/citadel/modules/network/serv_netspool.c +++ b/citadel/modules/network/serv_netspool.c @@ -182,6 +182,7 @@ void InspectQueuedRoom(SpoolControl **pSC, HashList *working_ignetcfg, HashList *the_netmap) { + struct CitContext *CCC = CC; SpoolControl *sc; int i = 0; @@ -204,7 +205,7 @@ void InspectQueuedRoom(SpoolControl **pSC, } if (sc->room.QRhighest <= sc->lastsent) { - syslog(LOG_DEBUG, "nothing to do for <%s>\n", room_to_spool->name); + QN_syslog(LOG_DEBUG, "nothing to do for <%s>\n", room_to_spool->name); free(sc); return; } @@ -353,16 +354,6 @@ void network_spoolout_room(SpoolControl *sc) syslog(LOG_INFO, "Networking started for <%s>\n", CCC->room.QRname); - /* If there are digest recipients, we have to build a digest */ - if (sc->Users[digestrecp] != NULL) { - - sc->digestfp = create_digest_file(&sc->room); - sc->newDigest = ftell(sc->digestfp) > 0; - if (sc->newDigest) { - fprintf(sc->digestfp, "Content-type: text/plain\n\n"); - } - } - CalcListID(sc); /* remember where we started... */ @@ -394,7 +385,7 @@ void network_spoolout_room(SpoolControl *sc) /* If we wrote a digest, deliver it and then close it */ - if (sc->digestfp != NULL) { + if (sc->Users[digestrecp] != NULL) { time_t now = time(NULL); time_t secs_today = now % (24 * 60 * 60); long delta = 0; @@ -405,23 +396,30 @@ void network_spoolout_room(SpoolControl *sc) } if ((secs_today < 300) && - (delta < 300) ) + (delta < 300)) { - 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 */ + 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) { fclose(sc->digestfp); sc->digestfp = NULL; - remove_digest_file(&sc->room); } /* Now rewrite the config file */ @@ -436,6 +434,53 @@ void network_spoolout_room(SpoolControl *sc) } } + +/* + * Check the use table. This is a list of messages which have recently + * arrived on the system. It is maintained and queried to prevent the same + * message from being entered into the database multiple times if it happens + * to arrive multiple times by accident. + */ +int network_usetable(struct CtdlMessage *msg) +{ + StrBuf *msgid; + struct CitContext *CCC = CC; + time_t now; + + /* Bail out if we can't generate a message ID */ + if ((msg == NULL) || CM_IsEmpty(msg, emessageId)) + { + return(0); + } + + /* Generate the message ID */ + msgid = NewStrBufPlain(CM_KEY(msg, emessageId)); + if (haschar(ChrPtr(msgid), '@') == 0) { + StrBufAppendBufPlain(msgid, HKEY("@"), 0); + if (!CM_IsEmpty(msg, eNodeName)) { + StrBufAppendBufPlain(msgid, CM_KEY(msg, eNodeName), 0); + } + else { + FreeStrBuf(&msgid); + return(0); + } + } + now = time(NULL); + if (CheckIfAlreadySeen("Networker Import", + msgid, + now, 0, + eCheckUpdate, + CCC->cs_pid, 0) != 0) + { + FreeStrBuf(&msgid); + return(1); + } + FreeStrBuf(&msgid); + + return(0); +} + + /* * Process a buffer containing a single message from a single file * from the inbound queue