commit 211bedd

default  ·  2023-04-13 15:12:07 +0000 UTC
parent bcde97c
New function notify_check_time().
2 files changed,  +29, -0
M data.c
M snac.h
M data.c
+28, -0
 1@@ -1477,6 +1477,34 @@ xs_list *inbox_list(void)
 2 
 3 /** notifications **/
 4 
 5+xs_str *notify_check_time(snac *snac, int reset)
 6+/* gets or resets the latest notification check time */
 7+{
 8+    xs_str *t = NULL;
 9+    xs *fn    = xs_fmt("%s/notifydate.txt", snac->basedir);
10+    FILE *f;
11+
12+    if (reset) {
13+        if ((f = fopen(fn, "w")) != NULL) {
14+            t = tid(0);
15+            fprintf(f, "%s\n", t);
16+            fclose(f);
17+        }
18+    }
19+    else {
20+        if ((f = fopen(fn, "r")) != NULL) {
21+            t = xs_readline(f);
22+            fclose(f);
23+        }
24+        else
25+            /* never set before */
26+            t = xs_fmt("%16.6f", 0.0);
27+    }
28+
29+    return t;
30+}
31+
32+
33 void notify_add(snac *snac, const char *type, const char *utype,
34                 const char *actor, const char *objid)
35 /* adds a new notification */
M snac.h
+1, -0
1@@ -137,6 +137,7 @@ d_char *history_list(snac *snac);
2 
3 void lastlog_write(snac *snac);
4 
5+xs_str *notify_check_time(snac *snac, int reset);
6 void notify_add(snac *snac, const char *type, const char *utype,
7                 const char *actor, const char *objid);
8