commit 156d5280196c948369b186999a74c7062272b5b2
parent 55fb7dcbef819478c8d54a0161fb1330622a762e
Author: default <nobody@localhost>
Date: Fri, 20 Dec 2024 09:04:17 +0100
Add contact metrics to og:description.
Diffstat:
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/data.c b/data.c
@@ -2842,7 +2842,7 @@ xs_str *notify_check_time(snac *snac, int reset)
xs_dict *markers_get(snac *snac, const xs_list *markers)
{
- xs_dict *data = NULL;
+ xs *data = NULL;
xs_dict *returns = xs_dict_new();
xs *fn = xs_fmt("%s/markers.json", snac->basedir);
const xs_str *v = NULL;
@@ -2868,7 +2868,7 @@ xs_dict *markers_get(snac *snac, const xs_list *markers)
xs_dict *markers_set(snac *snac, const char *home_marker, const char *notify_marker)
/* gets or sets notification marker */
{
- xs_dict *data = NULL;
+ xs *data = NULL;
xs_dict *written = xs_dict_new();
xs *fn = xs_fmt("%s/markers.json", snac->basedir);
FILE *f;
@@ -2882,19 +2882,21 @@ xs_dict *markers_set(snac *snac, const char *home_marker, const char *notify_mar
data = xs_dict_new();
if (!xs_is_null(home_marker)) {
- xs_dict *home = xs_dict_new();
+ xs *home = xs_dict_new();
+ xs *s_tid = tid(0);
home = xs_dict_append(home, "last_read_id", home_marker);
home = xs_dict_append(home, "version", xs_stock(0));
- home = xs_dict_append(home, "updated_at", tid(0));
+ home = xs_dict_append(home, "updated_at", s_tid);
data = xs_dict_set(data, "home", home);
written = xs_dict_append(written, "home", home);
}
if (!xs_is_null(notify_marker)) {
- xs_dict *notify = xs_dict_new();
+ xs *notify = xs_dict_new();
+ xs *s_tid = tid(0);
notify = xs_dict_append(notify, "last_read_id", notify_marker);
notify = xs_dict_append(notify, "version", xs_stock(0));
- notify = xs_dict_append(notify, "updated_at", tid(0));
+ notify = xs_dict_append(notify, "updated_at", s_tid);
data = xs_dict_set(data, "notifications", notify);
written = xs_dict_append(written, "notifications", notify);
}
diff --git a/html.c b/html.c
@@ -642,6 +642,17 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url)
else
s_desc = xs_dup(desc);
+ /* show metrics in og:description? */
+ if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) {
+ xs *fwers = follower_list(user);
+ xs *fwing = following_list(user);
+
+ xs *s1 = xs_fmt(L("%d following, %d followers ยท "),
+ xs_list_len(fwing), xs_list_len(fwers));
+
+ s_desc = xs_str_prepend_i(s_desc, s1);
+ }
+
/* shorten desc to a reasonable size */
for (n = 0; s_desc[n]; n++) {
if (n > 512 && (s_desc[n] == ' ' || s_desc[n] == '\n'))