summary refs log tree commit diff
path: root/notemap.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-01-26 21:03:12 -0500
committerJune McEnroe <june@causal.agency>2020-01-26 21:03:12 -0500
commitdfa9dc5fbd8a0b649da619899f7bf23756faae2c (patch)
tree965bd9f81b57687426d541dfef855744c25e0b70 /notemap.c
parentLog out after reading all notes (diff)
downloadnotemap-dfa9dc5fbd8a0b649da619899f7bf23756faae2c.tar.gz
notemap-dfa9dc5fbd8a0b649da619899f7bf23756faae2c.zip
Check envelope date rather than internal date
Diffstat (limited to '')
-rw-r--r--notemap.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/notemap.c b/notemap.c
index 2b0fe3b..0ba364b 100644
--- a/notemap.c
+++ b/notemap.c
@@ -250,6 +250,7 @@ static void append(
 			len = 0;
 		}
 		if (ch == '\n') {
+			// TODO: Check if last character was space or tab.
 			fprintf(msg, "\r\n");
 			len = 0;
 		} else if (ch == '\t' || (ch >= ' ' && ch <= '~' && ch != '=')) {
@@ -419,7 +420,7 @@ next:
 
 			break; case Search: {
 				if (!seq) goto append;
-				fprintf(imap, "%s FETCH %d INTERNALDATE\r\n", Atoms[Fetch], seq);
+				fprintf(imap, "%s FETCH %d ENVELOPE\r\n", Atoms[Fetch], seq);
 			}
 
 			break; case Fetch: {
@@ -451,9 +452,12 @@ append:
 		}
 
 		if (resp == Fetch) {
+			if (!strncmp(rest, "(FLAGS", 6)) continue;
+
+			// TODO: Factor out format string.
 			struct tm date = {0};
 			rest = strptime(
-				rest, "(INTERNALDATE \"%d-%b-%Y %H:%M:%S %z\")", &date
+				rest, "(ENVELOPE (\"%a, %e %b %Y %H:%M:%S %z\"", &date
 			);
 			if (!rest) errx(EX_PROTOCOL, "invalid INTERNALDATE");
 
@@ -464,6 +468,7 @@ append:
 			if (!force && status.st_mtime < mktime(&date)) {
 				errx(EX_TEMPFAIL, "%s: note has been modified in mailbox", note);
 			}
+			// TODO: Skip if times are the same.
 		}
 	}
 }