+ CtdlSubmitMsg(&RSSAggr->ThisMsg->Msg, &RSSAggr->recp, NULL, 0);
+
+ /* write the uidl to the use table so we don't store this item again */
+
+ CheckIfAlreadySeen("RSS Item Insert", RSSAggr->ThisMsg->MsgGUID, IO->Now, 0, eWrite, IO->ID, CCID);
+
+ if (GetNextHashPos(RSSAggr->Messages,
+ RSSAggr->Pos,
+ &len, &Key,
+ (void**) &RSSAggr->ThisMsg))
+ return NextDBOperation(IO, RSS_FetchNetworkUsetableEntry);
+ else
+ return eAbort;
+}
+
+eNextState RSS_FetchNetworkUsetableEntry(AsyncIO *IO)
+{
+ const char *Key;
+ long len;
+ rss_aggregator *Ctx = (rss_aggregator *) IO->Data;
+
+ /* Find out if we've already seen this item */
+// todo: expiry?
+#ifndef DEBUG_RSS
+ if (CheckIfAlreadySeen("RSS Item Seen",
+ Ctx->ThisMsg->MsgGUID,
+ IO->Now,
+ IO->Now - USETABLE_ANTIEXPIRE,
+ eCheckUpdate,
+ IO->ID, CCID)
+ != 0)
+ {
+ /* Item has already been seen */
+ EVRSSC_syslog(LOG_DEBUG,
+ "%s has already been seen\n",
+ ChrPtr(Ctx->ThisMsg->MsgGUID));
+
+ if (GetNextHashPos(Ctx->Messages,
+ Ctx->Pos,
+ &len, &Key,
+ (void**) &Ctx->ThisMsg))
+ return NextDBOperation(
+ IO,
+ RSS_FetchNetworkUsetableEntry);
+ else
+ return eAbort;
+ }
+ else
+#endif
+ {
+ NextDBOperation(IO, RSSSaveMessage);
+ return eSendMore;
+ }
+ return eSendMore;
+}
+
+eNextState RSSAggregator_AnalyseReply(AsyncIO *IO)
+{
+ u_char rawdigest[MD5_DIGEST_LEN];
+ struct MD5Context md5context;
+ StrBuf *guid;
+ rss_aggregator *Ctx = (rss_aggregator *) IO->Data;
+
+ if (IO->HttpReq.httpcode != 200)
+ {
+ StrBuf *ErrMsg;
+ long lens[2];
+ const char *strs[2];
+
+ ErrMsg = NewStrBuf();
+ EVRSSC_syslog(LOG_ALERT, "need a 200, got a %ld !\n",
+ IO->HttpReq.httpcode);
+
+ strs[0] = ChrPtr(Ctx->Url);
+ lens[0] = StrLength(Ctx->Url);
+
+ strs[1] = ChrPtr(Ctx->rooms);
+ lens[1] = StrLength(Ctx->rooms);
+ StrBufPrintf(ErrMsg,
+ "Error while RSS-Aggregation Run of %s\n"
+ " need a 200, got a %ld !\n"
+ " Response text was: \n"
+ " \n %s\n",
+ ChrPtr(Ctx->Url),
+ IO->HttpReq.httpcode,
+ ChrPtr(IO->HttpReq.ReplyData));
+ CtdlAideFPMessage(
+ ChrPtr(ErrMsg),
+ "RSS Aggregation run failure",
+ 2, strs, (long*) &lens,
+ IO->Now,
+ IO->ID, CCID);
+ FreeStrBuf(&ErrMsg);
+ return eAbort;
+ }
+
+ 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
+
+ if (CheckIfAlreadySeen("RSS Whole",
+ guid,
+ IO->Now,
+ IO->Now - USETABLE_ANTIEXPIRE,
+ eCheckUpdate,
+ IO->ID, CCID)
+ != 0)
+ {
+ FreeStrBuf(&guid);
+
+ return eAbort;
+ }
+ FreeStrBuf(&guid);
+#endif
+ return RSSAggregator_ParseReply(IO);
+}
+
+eNextState RSSAggregator_FinishHttp(AsyncIO *IO)
+{
+ return QueueDBOperation(IO, RSSAggregator_AnalyseReply);
+}