commit 156d528

default  ·  2024-12-20 08:04:17 +0000 UTC
parent 55fb7dc
Add contact metrics to og:description.
2 files changed,  +19, -6
M data.c
M html.c
M data.c
+8, -6
 1@@ -2842,7 +2842,7 @@ xs_str *notify_check_time(snac *snac, int reset)
 2 
 3 xs_dict *markers_get(snac *snac, const xs_list *markers)
 4 {
 5-    xs_dict *data = NULL;
 6+    xs *data = NULL;
 7     xs_dict *returns = xs_dict_new();
 8     xs *fn = xs_fmt("%s/markers.json", snac->basedir);
 9     const xs_str *v = NULL;
10@@ -2868,7 +2868,7 @@ xs_dict *markers_get(snac *snac, const xs_list *markers)
11 xs_dict *markers_set(snac *snac, const char *home_marker, const char *notify_marker)
12 /* gets or sets notification marker */
13 {
14-    xs_dict *data = NULL;
15+    xs *data = NULL;
16     xs_dict *written = xs_dict_new();
17     xs *fn = xs_fmt("%s/markers.json", snac->basedir);
18     FILE *f;
19@@ -2882,19 +2882,21 @@ xs_dict *markers_set(snac *snac, const char *home_marker, const char *notify_mar
20         data = xs_dict_new();
21 
22     if (!xs_is_null(home_marker)) {
23-        xs_dict *home = xs_dict_new();
24+        xs *home = xs_dict_new();
25+        xs *s_tid = tid(0);
26         home = xs_dict_append(home, "last_read_id", home_marker);
27         home = xs_dict_append(home, "version", xs_stock(0));
28-        home = xs_dict_append(home, "updated_at", tid(0));
29+        home = xs_dict_append(home, "updated_at", s_tid);
30         data = xs_dict_set(data, "home", home);
31         written = xs_dict_append(written, "home", home);
32     }
33 
34     if (!xs_is_null(notify_marker)) {
35-        xs_dict *notify = xs_dict_new();
36+        xs *notify = xs_dict_new();
37+        xs *s_tid = tid(0);
38         notify = xs_dict_append(notify, "last_read_id", notify_marker);
39         notify = xs_dict_append(notify, "version", xs_stock(0));
40-        notify = xs_dict_append(notify, "updated_at", tid(0));
41+        notify = xs_dict_append(notify, "updated_at", s_tid);
42         data = xs_dict_set(data, "notifications", notify);
43         written = xs_dict_append(written, "notifications", notify);
44     }
M html.c
+11, -0
 1@@ -642,6 +642,17 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url)
 2     else
 3         s_desc = xs_dup(desc);
 4 
 5+    /* show metrics in og:description? */
 6+    if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) {
 7+        xs *fwers = follower_list(user);
 8+        xs *fwing = following_list(user);
 9+
10+        xs *s1 = xs_fmt(L("%d following, %d followers ยท "),
11+            xs_list_len(fwing), xs_list_len(fwers));
12+
13+        s_desc = xs_str_prepend_i(s_desc, s1);
14+    }
15+
16     /* shorten desc to a reasonable size */
17     for (n = 0; s_desc[n]; n++) {
18         if (n > 512 && (s_desc[n] == ' ' || s_desc[n] == '\n'))