+eNextState RSSSaveMessage(AsyncIO *IO)
+{
+ long len;
+ const char *Key;
+ rss_aggregator *RSSAggr = (rss_aggregator *) IO->Data;
+
+ rss_format_item(RSSAggr->ThisMsg);
+
+ RSSAggr->ThisMsg->Msg.cm_fields['M'] =
+ SmashStrBuf(&RSSAggr->ThisMsg->Message);
+
+ CtdlSubmitMsg(&RSSAggr->ThisMsg->Msg, &RSSAggr->recp, NULL, 0);
+
+ /* write the uidl to the use table so we don't store this item again */
+ cdb_store(CDB_USETABLE,
+ SKEY(RSSAggr->ThisMsg->MsgGUID),
+ &RSSAggr->ThisMsg->ut,
+ sizeof(struct UseTable) );
+
+ 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;
+ struct cdbdata *cdbut;
+ rss_aggregator *Ctx = (rss_aggregator *) IO->Data;
+
+ /* Find out if we've already seen this item */
+ strcpy(Ctx->ThisMsg->ut.ut_msgid,
+ ChrPtr(Ctx->ThisMsg->MsgGUID)); /// TODO
+ Ctx->ThisMsg->ut.ut_timestamp = time(NULL);
+
+ cdbut = cdb_fetch(CDB_USETABLE, SKEY(Ctx->ThisMsg->MsgGUID));
+#ifndef DEBUG_RSS
+ if (cdbut != NULL) {
+ /* Item has already been seen */
+ EVRSSC_syslog(LOG_DEBUG,
+ "%s has already been seen\n",
+ ChrPtr(Ctx->ThisMsg->MsgGUID));
+ cdb_free(cdbut);
+
+ /* rewrite the record anyway, to update the timestamp */
+ cdb_store(CDB_USETABLE,
+ SKEY(Ctx->ThisMsg->MsgGUID),
+ &Ctx->ThisMsg->ut, sizeof(struct UseTable) );
+
+ 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;
+ }
+}
+
+eNextState RSSAggregator_AnalyseReply(AsyncIO *IO)
+{
+ struct UseTable ut;
+ u_char rawdigest[MD5_DIGEST_LEN];
+ struct MD5Context md5context;
+ StrBuf *guid;
+ struct cdbdata *cdbut;
+ 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);
+ FreeStrBuf(&ErrMsg);
+ return eAbort;
+ }