mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-25 16:53:37 +00:00
Add contact metrics to og:description.
This commit is contained in:
parent
55fb7dcbef
commit
156d528019
2 changed files with 19 additions and 6 deletions
14
data.c
14
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);
|
||||
}
|
||||
|
|
11
html.c
11
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'))
|
||||
|
|
Loading…
Reference in a new issue