+ // check the use table
+ StrBuf *u = NewStrBuf();
+ StrBufAppendPrintf(u, "rss/%s", r->item_id);
+ int already_seen = CheckIfAlreadySeen(u);
+ FreeStrBuf(&u);
+
+ if (already_seen == 0) {
+
+ // Compose the message text
+ StrBuf *TheMessage = NewStrBuf();
+ StrBufAppendPrintf(TheMessage,
+ "Content-type: text/html\n\n"
+ "\n\n"
+ "<html><head></head><body>"
+ );
+
+ if (r->description != NULL) {
+ StrBufAppendPrintf(TheMessage, "%s<br><br>\r\n", r->description);
+ free(r->description);
+ r->description = NULL;
+ }
+
+ if (r->link != NULL) {
+ StrBufAppendPrintf(TheMessage, "<a href=\"%s\">%s</a>\r\n", r->link, r->link);
+ free(r->link);
+ r->link = NULL;
+ }
+
+ StrBufAppendPrintf(TheMessage, "</body></html>\r\n");
+ CM_SetField(r->msg, eMesageText, ChrPtr(TheMessage), StrLength(TheMessage));
+ FreeStrBuf(&TheMessage);
+
+ if (CM_IsEmpty(r->msg, eAuthor)) {
+ CM_SetField(r->msg, eAuthor, HKEY("rss"));
+ }
+
+ if (CM_IsEmpty(r->msg, eTimestamp)) {
+ CM_SetFieldLONG(r->msg, eTimestamp, time(NULL));
+ }
+
+ // Save it to the room(s)
+ struct rssroom *rr = NULL;
+ long msgnum = (-1);
+ for (rr=r->rooms; rr!=NULL; rr=rr->next) {
+ if (rr == r->rooms) {
+ msgnum = CtdlSubmitMsg(r->msg, NULL, rr->room, 0);
+ }
+ else {
+ CtdlSaveMsgPointerInRoom(rr->room, msgnum, 0, NULL);
+ }
+ syslog(LOG_DEBUG, "rssclient: saved message %ld to %s", msgnum, rr->room);
+ }
+ }
+ else {
+ syslog(LOG_DEBUG, "rssclient: already seen %s", r->item_id);
+ }
+
+ CM_Free(r->msg);
+ r->msg = NULL;
+ }