+
+ MD5Init(&md5context);
+
+ MD5Update(&md5context,
+ (const unsigned char*)SKEY(IO->HttpReq.ReplyData));
+
+ MD5Update(&md5context,
+ (const unsigned char*)SKEY(Ctx->Url));
+
+ MD5Final(rawdigest, &md5context);
+ guid = NewStrBufPlain(NULL,
+ MD5_DIGEST_LEN * 2 + 12 /* _rss2ctdl*/);
+ StrBufHexEscAppend(guid, NULL, rawdigest, MD5_DIGEST_LEN);
+ StrBufAppendBufPlain(guid, HKEY("_rssFM"), 0);
+ if (StrLength(guid) > 40)
+ StrBufCutAt(guid, 40, NULL);
+ /* Find out if we've already seen this item */
+
+#ifndef DEBUG_RSS
+ cdbut = cdb_fetch(CDB_USETABLE, SKEY(guid));
+ if (cdbut != NULL) {
+ memcpy(&ut, cdbut->ptr,
+ ((cdbut->len > sizeof(struct UseTable)) ?
+ sizeof(struct UseTable) : cdbut->len));
+
+ if (IO->Now - ut.ut_timestamp >
+ 60 * 60 * 24 * 4)
+ {
+ /* Item has already been seen in the last 4 days */
+ EVRSSC_syslog(LOG_DEBUG,
+ "%s has already been seen\n",
+ ChrPtr(Ctx->Url));
+ }
+ cdb_free(cdbut);
+ }
+
+ memcpy(ut.ut_msgid, SKEY(guid));
+ ut.ut_timestamp = IO->Now;
+
+ /* rewrite the record anyway, to update the timestamp */
+ cdb_store(CDB_USETABLE,
+ SKEY(guid),
+ &ut, sizeof(struct UseTable) );
+ FreeStrBuf(&guid);
+ if (cdbut != NULL) return eAbort;
+#endif
+ return RSSAggregator_ParseReply(IO);
+}
+
+eNextState RSSAggregator_FinishHttp(AsyncIO *IO)
+{
+ return QueueDBOperation(IO, RSSAggregator_AnalyseReply);
+}
+