X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=citadel%2Fmodules%2Fnetwork%2Fserv_netspool.c;fp=citadel%2Fmodules%2Fnetwork%2Fserv_netspool.c;h=df1c225dfa0846686281608c87c09c2574842fdf;hp=0edb1f11efa0e240bcf7c7c3d79ead11d21b3934;hb=2e810d36a66a6cc42c345bd924b4e2b7669af8cd;hpb=4ddf8d68536f54ac497617ae786afd0248507b24 diff --git a/citadel/modules/network/serv_netspool.c b/citadel/modules/network/serv_netspool.c index 0edb1f11e..df1c225df 100644 --- a/citadel/modules/network/serv_netspool.c +++ b/citadel/modules/network/serv_netspool.c @@ -434,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