diff options
| author | 2024-12-20 09:04:17 +0100 | |
|---|---|---|
| committer | 2024-12-20 09:04:17 +0100 | |
| commit | 156d5280196c948369b186999a74c7062272b5b2 (patch) | |
| tree | 18f5c38d052b4ace38142ce09202a4d3f3e6be72 | |
| parent | Updated RELEASE_NOTES. (diff) | |
| download | penes-snac2-156d5280196c948369b186999a74c7062272b5b2.tar.gz penes-snac2-156d5280196c948369b186999a74c7062272b5b2.tar.xz penes-snac2-156d5280196c948369b186999a74c7062272b5b2.zip | |
Add contact metrics to og:description.
| -rw-r--r-- | data.c | 14 | ||||
| -rw-r--r-- | html.c | 11 |
2 files changed, 19 insertions, 6 deletions
| @@ -2842,7 +2842,7 @@ xs_str *notify_check_time(snac *snac, int reset) | |||
| 2842 | 2842 | ||
| 2843 | xs_dict *markers_get(snac *snac, const xs_list *markers) | 2843 | xs_dict *markers_get(snac *snac, const xs_list *markers) |
| 2844 | { | 2844 | { |
| 2845 | xs_dict *data = NULL; | 2845 | xs *data = NULL; |
| 2846 | xs_dict *returns = xs_dict_new(); | 2846 | xs_dict *returns = xs_dict_new(); |
| 2847 | xs *fn = xs_fmt("%s/markers.json", snac->basedir); | 2847 | xs *fn = xs_fmt("%s/markers.json", snac->basedir); |
| 2848 | const xs_str *v = NULL; | 2848 | const xs_str *v = NULL; |
| @@ -2868,7 +2868,7 @@ xs_dict *markers_get(snac *snac, const xs_list *markers) | |||
| 2868 | xs_dict *markers_set(snac *snac, const char *home_marker, const char *notify_marker) | 2868 | xs_dict *markers_set(snac *snac, const char *home_marker, const char *notify_marker) |
| 2869 | /* gets or sets notification marker */ | 2869 | /* gets or sets notification marker */ |
| 2870 | { | 2870 | { |
| 2871 | xs_dict *data = NULL; | 2871 | xs *data = NULL; |
| 2872 | xs_dict *written = xs_dict_new(); | 2872 | xs_dict *written = xs_dict_new(); |
| 2873 | xs *fn = xs_fmt("%s/markers.json", snac->basedir); | 2873 | xs *fn = xs_fmt("%s/markers.json", snac->basedir); |
| 2874 | FILE *f; | 2874 | FILE *f; |
| @@ -2882,19 +2882,21 @@ xs_dict *markers_set(snac *snac, const char *home_marker, const char *notify_mar | |||
| 2882 | data = xs_dict_new(); | 2882 | data = xs_dict_new(); |
| 2883 | 2883 | ||
| 2884 | if (!xs_is_null(home_marker)) { | 2884 | if (!xs_is_null(home_marker)) { |
| 2885 | xs_dict *home = xs_dict_new(); | 2885 | xs *home = xs_dict_new(); |
| 2886 | xs *s_tid = tid(0); | ||
| 2886 | home = xs_dict_append(home, "last_read_id", home_marker); | 2887 | home = xs_dict_append(home, "last_read_id", home_marker); |
| 2887 | home = xs_dict_append(home, "version", xs_stock(0)); | 2888 | home = xs_dict_append(home, "version", xs_stock(0)); |
| 2888 | home = xs_dict_append(home, "updated_at", tid(0)); | 2889 | home = xs_dict_append(home, "updated_at", s_tid); |
| 2889 | data = xs_dict_set(data, "home", home); | 2890 | data = xs_dict_set(data, "home", home); |
| 2890 | written = xs_dict_append(written, "home", home); | 2891 | written = xs_dict_append(written, "home", home); |
| 2891 | } | 2892 | } |
| 2892 | 2893 | ||
| 2893 | if (!xs_is_null(notify_marker)) { | 2894 | if (!xs_is_null(notify_marker)) { |
| 2894 | xs_dict *notify = xs_dict_new(); | 2895 | xs *notify = xs_dict_new(); |
| 2896 | xs *s_tid = tid(0); | ||
| 2895 | notify = xs_dict_append(notify, "last_read_id", notify_marker); | 2897 | notify = xs_dict_append(notify, "last_read_id", notify_marker); |
| 2896 | notify = xs_dict_append(notify, "version", xs_stock(0)); | 2898 | notify = xs_dict_append(notify, "version", xs_stock(0)); |
| 2897 | notify = xs_dict_append(notify, "updated_at", tid(0)); | 2899 | notify = xs_dict_append(notify, "updated_at", s_tid); |
| 2898 | data = xs_dict_set(data, "notifications", notify); | 2900 | data = xs_dict_set(data, "notifications", notify); |
| 2899 | written = xs_dict_append(written, "notifications", notify); | 2901 | written = xs_dict_append(written, "notifications", notify); |
| 2900 | } | 2902 | } |
| @@ -642,6 +642,17 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url) | |||
| 642 | else | 642 | else |
| 643 | s_desc = xs_dup(desc); | 643 | s_desc = xs_dup(desc); |
| 644 | 644 | ||
| 645 | /* show metrics in og:description? */ | ||
| 646 | if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) { | ||
| 647 | xs *fwers = follower_list(user); | ||
| 648 | xs *fwing = following_list(user); | ||
| 649 | |||
| 650 | xs *s1 = xs_fmt(L("%d following, %d followers ยท "), | ||
| 651 | xs_list_len(fwing), xs_list_len(fwers)); | ||
| 652 | |||
| 653 | s_desc = xs_str_prepend_i(s_desc, s1); | ||
| 654 | } | ||
| 655 | |||
| 645 | /* shorten desc to a reasonable size */ | 656 | /* shorten desc to a reasonable size */ |
| 646 | for (n = 0; s_desc[n]; n++) { | 657 | for (n = 0; s_desc[n]; n++) { |
| 647 | if (n > 512 && (s_desc[n] == ' ' || s_desc[n] == '\n')) | 658 | if (n > 512 && (s_desc[n] == ' ' || s_desc[n] == '\n')) |