summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-04-13 17:12:07 +0200
committerdefault <nobody@localhost>2023-04-13 17:12:07 +0200
commit211bedd4978c4711f0e2399b38ccb6e76e39856d (patch)
tree91ec989f5842f2c61734218f552790724ef1a44d
parentbcde97c2d53f9c94c6ced2717945affa4ede554c (diff)
New function notify_check_time().
-rw-r--r--data.c28
-rw-r--r--snac.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/data.c b/data.c
index a98e9e5..cf66b9a 100644
--- a/data.c
+++ b/data.c
@@ -1477,6 +1477,34 @@ xs_list *inbox_list(void)
/** notifications **/
+xs_str *notify_check_time(snac *snac, int reset)
+/* gets or resets the latest notification check time */
+{
+ xs_str *t = NULL;
+ xs *fn = xs_fmt("%s/notifydate.txt", snac->basedir);
+ FILE *f;
+
+ if (reset) {
+ if ((f = fopen(fn, "w")) != NULL) {
+ t = tid(0);
+ fprintf(f, "%s\n", t);
+ fclose(f);
+ }
+ }
+ else {
+ if ((f = fopen(fn, "r")) != NULL) {
+ t = xs_readline(f);
+ fclose(f);
+ }
+ else
+ /* never set before */
+ t = xs_fmt("%16.6f", 0.0);
+ }
+
+ return t;
+}
+
+
void notify_add(snac *snac, const char *type, const char *utype,
const char *actor, const char *objid)
/* adds a new notification */
diff --git a/snac.h b/snac.h
index a707f16..e201801 100644
--- a/snac.h
+++ b/snac.h
@@ -137,6 +137,7 @@ d_char *history_list(snac *snac);
void lastlog_write(snac *snac);
+xs_str *notify_check_time(snac *snac, int reset);
void notify_add(snac *snac, const char *type, const char *utype,
const char *actor, const char *objid);