X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Frssclient%2Fserv_rssclient.c;h=11ffb905f138de66eb3b8525ab89b543155867a6;hb=c71df26b9d35c07eb9c1322a7e83caa86337ad82;hp=0b89a9563ac5c4f011321a8dbd82db4ceb0ef402;hpb=984ea5827d1658847bf958cb9a373d4306de0c24;p=citadel.git diff --git a/citadel/modules/rssclient/serv_rssclient.c b/citadel/modules/rssclient/serv_rssclient.c index 0b89a9563..11ffb905f 100644 --- a/citadel/modules/rssclient/serv_rssclient.c +++ b/citadel/modules/rssclient/serv_rssclient.c @@ -1,7 +1,9 @@ /* - * Bring external RSS feeds into rooms. + * Bring external RSS and/or Atom feeds into rooms. This module implements a + * very loose parser that scrapes both kinds of feeds and is not picky about + * the standards compliance of the source data. * - * Copyright (c) 2007-2017 by the citadel.org team + * Copyright (c) 2007-2018 by the citadel.org team * * This program is open source software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3. @@ -71,7 +73,6 @@ struct rssparser { }; time_t last_run = 0L; -struct CitContext rss_CC; struct rssurl *rsstodo = NULL; @@ -205,13 +206,20 @@ void rss_end_element(void *data, const char *el) } } - else if (!strcasecmp(el, "author")) { // author of item (rss and maybe atom) + else if (!strcasecmp(el, "creator")) { // can be used if is not present if ((r->msg != NULL) && (CM_IsEmpty(r->msg, eAuthor))) { CM_SetField(r->msg, eAuthor, ChrPtr(r->CData), StrLength(r->CData)); striplt(r->msg->cm_fields[eAuthor]); } } + else if (!strcasecmp(el, "author")) { // supercedes if both are present + if (r->msg != NULL) { + CM_SetField(r->msg, eAuthor, ChrPtr(r->CData), StrLength(r->CData)); // CM_SetField will free() the previous value + striplt(r->msg->cm_fields[eAuthor]); + } + } + else if (!strcasecmp(el, "pubdate")) { // date/time stamp (rss) Sat, 25 Feb 2017 14:28:01 EST if ((r->msg)&&(r->msg->cm_fields[eTimestamp]==NULL)) { CM_SetFieldLONG(r->msg, eTimestamp, parsedate(ChrPtr(r->CData))); @@ -437,7 +445,6 @@ void rssclient_scan(void) { return; } - become_session(&rss_CC); syslog(LOG_DEBUG, "rssclient: started"); CtdlForEachRoom(rssclient_scan_room, NULL); rss_pull_feeds(); @@ -454,10 +461,6 @@ CTDL_MODULE_INIT(rssclient) syslog(LOG_INFO, "rssclient: using %s", curl_version()); CtdlRegisterSessionHook(rssclient_scan, EVT_TIMER, PRIO_AGGR + 300); } - else - { - CtdlFillSystemContext(&rss_CC, "rssclient"); - } return "rssclient"; }