- /* If we get to this point, the message is on its way. Read it. */
- body = CtdlReadMessageBody(".", config.c_maxmsglen, NULL, 1, sock);
- if (body == NULL) goto bail;
-
- lprintf(CTDL_DEBUG, "Converting message...\n");
- msg = convert_internet_message(body);
- body = NULL; /* yes, this should be dereferenced, NOT freed */
-
- /* Do Something With It (tm) */
- msgnum = CtdlSubmitMsg(msg, NULL, roomname);
- if (msgnum > 0L) {
- /* Message has been committed to the store */
-
- if (delete_from_server) {
- snprintf(buf, sizeof buf, "DELE %d\r", msglist[i]);
- lprintf(CTDL_DEBUG, "<%s\n", buf);
- if (sock_puts(sock, buf) <0) goto bail;
- if (sock_getln(sock, buf, sizeof buf) < 0) goto bail;
- lprintf(CTDL_DEBUG, ">%s\n", buf); /* errors here are non-fatal */
+ /* rewrite the record anyway, to update the timestamp */
+ strcpy(ut.ut_msgid, utmsgid);
+ ut.ut_timestamp = time(NULL);
+ cdb_store(CDB_USETABLE, utmsgid, strlen(utmsgid), &ut, sizeof(struct UseTable) );
+ }
+
+ else {
+ /* message has not been seen -- fetch it! */
+ lprintf(CTDL_DEBUG, "%s has NOT BEEN SEEN\n", utmsgid);
+
+ /* Tell the server to fetch the message */
+ snprintf(buf, sizeof buf, "RETR %d\r", msglist[i]);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
+ if (sock_puts(sock, buf) <0) goto bail;
+ if (sock_getln(sock, buf, sizeof buf) < 0) goto bail;
+ lprintf(CTDL_DEBUG, ">%s\n", buf);
+ if (strncasecmp(buf, "+OK", 3)) goto bail;
+
+ /* If we get to this point, the message is on its way. Read it. */
+ body = CtdlReadMessageBody(".", config.c_maxmsglen, NULL, 1, sock);
+ if (body == NULL) goto bail;
+
+ lprintf(CTDL_DEBUG, "Converting message...\n");
+ msg = convert_internet_message(body);
+ body = NULL; /* yes, this should be dereferenced, NOT freed */
+
+ /* Do Something With It (tm) */
+ msgnum = CtdlSubmitMsg(msg, NULL, roomname);
+ if (msgnum > 0L) {
+ /* Message has been committed to the store */
+
+ if (delete_from_server) {
+ snprintf(buf, sizeof buf, "DELE %d\r", msglist[i]);
+ lprintf(CTDL_DEBUG, "<%s\n", buf);
+ if (sock_puts(sock, buf) <0) goto bail;
+ if (sock_getln(sock, buf, sizeof buf) < 0) goto bail;
+ lprintf(CTDL_DEBUG, ">%s\n", buf); /* errors here are non-fatal */
+ }
+
+ /* write the uidl to the use table so we don't fetch this message again */
+ strcpy(ut.ut_msgid, utmsgid);
+ ut.ut_timestamp = time(NULL);
+ cdb_store(CDB_USETABLE, utmsgid, strlen(utmsgid),
+ &ut, sizeof(struct UseTable) );