]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/rssclient/serv_rssclient.c
cURL: put error description into the status message.
[citadel.git] / citadel / modules / rssclient / serv_rssclient.c
index 648d02d0b4c40353e879fd1dc7a85343764eb829..f9e2a312afe273e7a137c850cac798cc81bc9eba 100644 (file)
@@ -274,11 +274,22 @@ void AppendLink(StrBuf *Message,
 }
 
 
-void rss_format_item(networker_save_message *SaveMsg)
+int rss_format_item(AsyncIO *IO, networker_save_message *SaveMsg)
 {
        StrBuf *Message;
        int msglen = 0;
 
+       if (StrLength(SaveMsg->description) + 
+           StrLength(SaveMsg->link) + 
+           StrLength(SaveMsg->linkTitle) + 
+           StrLength(SaveMsg->reLink) +
+           StrLength(SaveMsg->reLinkTitle) +
+           StrLength(SaveMsg->title) == 0)
+       {
+               EVRSSCM_syslog(LOG_INFO, "Refusing to save empty message.");
+               return 0;
+       }
+
        if (SaveMsg->author_or_creator != NULL) {
 
                char *From;
@@ -375,8 +386,8 @@ void rss_format_item(networker_save_message *SaveMsg)
        AppendLink(Message, SaveMsg->reLink, SaveMsg->reLinkTitle, "Reply to this");
        StrBufAppendBufPlain(Message, HKEY("</body></html>\n"), 0);
 
-
        SaveMsg->Message = Message;
+       return 1;
 }
 
 eNextState RSSSaveMessage(AsyncIO *IO)
@@ -385,16 +396,17 @@ eNextState RSSSaveMessage(AsyncIO *IO)
        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 */
+       if (rss_format_item(IO, RSSAggr->ThisMsg))
+       {
+               RSSAggr->ThisMsg->Msg.cm_fields['M'] =
+                       SmashStrBuf(&RSSAggr->ThisMsg->Message);
 
-       CheckIfAlreadySeen("RSS Item Insert", RSSAggr->ThisMsg->MsgGUID, IO->Now, 0, eWrite, IO->ID, CCID);
+               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, CCID, IO->ID);
+       }
 
        if (GetNextHashPos(RSSAggr->Messages,
                           RSSAggr->Pos,
@@ -420,7 +432,7 @@ eNextState RSS_FetchNetworkUsetableEntry(AsyncIO *IO)
                               IO->Now,
                               IO->Now - USETABLE_ANTIEXPIRE_HIRES,
                               eCheckUpdate,
-                              IO->ID, CCID)
+                              CCID, IO->ID)
            != 0)
        {
                /* Item has already been seen */
@@ -503,14 +515,23 @@ eNextState RSSAggregator_AnalyseReply(AsyncIO *IO)
 
                strs[1] = ChrPtr(Ctx->rooms);
                lens[1] = StrLength(Ctx->rooms);
+
+               if (IO->HttpReq.CurlError == NULL)
+                       IO->HttpReq.CurlError = "";
+
                StrBufPrintf(ErrMsg,
                             "Error while RSS-Aggregation Run of %s\n"
                             " need a 200, got a %ld !\n"
+                            " Curl Error message: \n%s / %s\n"
                             " Response text was: \n"
                             " \n %s\n",
                             ChrPtr(Ctx->Url),
                             IO->HttpReq.httpcode,
-                            ChrPtr(IO->HttpReq.ReplyData));
+                            IO->HttpReq.errdesc,
+                            IO->HttpReq.CurlError,
+                            ChrPtr(IO->HttpReq.ReplyData)
+                       );
+
                CtdlAideFPMessage(
                        ChrPtr(ErrMsg),
                        "RSS Aggregation run failure",
@@ -575,7 +596,7 @@ eNextState RSSAggregator_AnalyseReply(AsyncIO *IO)
                               IO->Now,
                               IO->Now - USETABLE_ANTIEXPIRE,
                               eCheckUpdate,
-                              IO->ID, CCID)
+                              CCID, IO->ID)
            != 0)
        {
                FreeStrBuf(&guid);
@@ -591,7 +612,6 @@ eNextState RSSAggregator_AnalyseReply(AsyncIO *IO)
 
 eNextState RSSAggregator_FinishHttp(AsyncIO *IO)
 {
-       StopCurlWatchers(IO);
        return CurlQueueDBOperation(IO, RSSAggregator_AnalyseReply);
 }