summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RELEASE_NOTES.md2
-rw-r--r--activitypub.c6
-rw-r--r--data.c17
-rw-r--r--html.c43
-rw-r--r--mastoapi.c16
-rw-r--r--po/de_DE.po2
-rw-r--r--po/ru.po8
-rw-r--r--snac.h2
-rw-r--r--utils.c3
9 files changed, 57 insertions, 42 deletions
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 21c2153..484e425 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -4,6 +4,8 @@
4 4
5The number of pending follow confirmations is shown next to the "people" link. 5The number of pending follow confirmations is shown next to the "people" link.
6 6
7Faster performance metrics (contributed by dandelions).
8
7Mastodon API: added follow confirmation endpoints. 9Mastodon API: added follow confirmation endpoints.
8 10
9## 2.77 "Ugly Links Everywhere" 11## 2.77 "Ugly Links Everywhere"
diff --git a/activitypub.c b/activitypub.c
index 3ff51ad..c06d8df 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -3204,8 +3204,7 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path,
3204 int total = 0; 3204 int total = 0;
3205 3205
3206 if (show_contact_metrics) { 3206 if (show_contact_metrics) {
3207 xs *l = follower_list(&snac); 3207 total = follower_list_len(&snac);
3208 total = xs_list_len(l);
3209 } 3208 }
3210 3209
3211 xs *id = xs_fmt("%s/%s", snac.actor, p_path); 3210 xs *id = xs_fmt("%s/%s", snac.actor, p_path);
@@ -3216,8 +3215,7 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path,
3216 int total = 0; 3215 int total = 0;
3217 3216
3218 if (show_contact_metrics) { 3217 if (show_contact_metrics) {
3219 xs *l = following_list(&snac); 3218 total = following_list_len(&snac);
3220 total = xs_list_len(l);
3221 } 3219 }
3222 3220
3223 xs *id = xs_fmt("%s/%s", snac.actor, p_path); 3221 xs *id = xs_fmt("%s/%s", snac.actor, p_path);
diff --git a/data.c b/data.c
index 8ca271d..631a68b 100644
--- a/data.c
+++ b/data.c
@@ -1215,6 +1215,14 @@ int follower_check(snac *snac, const char *actor)
1215} 1215}
1216 1216
1217 1217
1218int follower_list_len(snac *snac)
1219/* returns the number of followers */
1220{
1221 xs *list = object_user_cache_list(snac, "followers", XS_ALL, 0);
1222 return xs_list_len(list);
1223}
1224
1225
1218xs_list *follower_list(snac *snac) 1226xs_list *follower_list(snac *snac)
1219/* returns the list of followers */ 1227/* returns the list of followers */
1220{ 1228{
@@ -1709,6 +1717,15 @@ int following_get(snac *snac, const char *actor, xs_dict **data)
1709} 1717}
1710 1718
1711 1719
1720int following_list_len(snac *snac)
1721/* returns number of people being followed */
1722{
1723 xs *spec = xs_fmt("%s/following/" "*_a.json", snac->basedir);
1724 xs *glist = xs_glob(spec, 0, 0);
1725 return xs_list_len(glist);
1726}
1727
1728
1712xs_list *following_list(snac *snac) 1729xs_list *following_list(snac *snac)
1713/* returns the list of people being followed */ 1730/* returns the list of people being followed */
1714{ 1731{
diff --git a/html.c b/html.c
index b27db7a..de2fdce 100644
--- a/html.c
+++ b/html.c
@@ -332,7 +332,8 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
332} 332}
333 333
334 334
335xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, const char *proxy, const char *md5) 335xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg,
336 const char *proxy, const char *md5, const char *lang)
336{ 337{
337 xs *actor = NULL; 338 xs *actor = NULL;
338 xs_html *actor_icon = NULL; 339 xs_html *actor_icon = NULL;
@@ -341,7 +342,6 @@ xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, con
341 const char *date = NULL; 342 const char *date = NULL;
342 const char *udate = NULL; 343 const char *udate = NULL;
343 const char *url = NULL; 344 const char *url = NULL;
344 const char *lang = NULL;
345 int priv = 0; 345 int priv = 0;
346 const char *type = xs_dict_get(msg, "type"); 346 const char *type = xs_dict_get(msg, "type");
347 347
@@ -353,16 +353,6 @@ xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, con
353 date = xs_dict_get(msg, "published"); 353 date = xs_dict_get(msg, "published");
354 udate = xs_dict_get(msg, "updated"); 354 udate = xs_dict_get(msg, "updated");
355 355
356 lang = xs_dict_get(msg, "contentMap");
357 if (xs_is_dict(lang)) {
358 const char *v;
359 int c = 0;
360
361 xs_dict_next(lang, &lang, &v, &c);
362 }
363 else
364 lang = NULL;
365
366 actor_icon = html_actor_icon(user, actor, date, udate, url, priv, 0, proxy, lang, md5); 356 actor_icon = html_actor_icon(user, actor, date, udate, url, priv, 0, proxy, lang, md5);
367 } 357 }
368 358
@@ -821,11 +811,7 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url)
821 811
822 /* show metrics in og:description? */ 812 /* show metrics in og:description? */
823 if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) { 813 if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) {
824 xs *fwers = follower_list(user); 814 xs *s1 = xs_fmt(L("%d following, %d followers"), following_list_len(user), follower_list_len(user));
825 xs *fwing = following_list(user);
826
827 xs *s1 = xs_fmt(L("%d following, %d followers"),
828 xs_list_len(fwing), xs_list_len(fwers));
829 815
830 s1 = xs_str_cat(s1, " · "); 816 s1 = xs_str_cat(s1, " · ");
831 817
@@ -1166,11 +1152,7 @@ static xs_html *html_user_body(snac *user, int read_only)
1166 } 1152 }
1167 1153
1168 if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) { 1154 if (xs_is_true(xs_dict_get(user->config, "show_contact_metrics"))) {
1169 xs *fwers = follower_list(user); 1155 xs *s1 = xs_fmt(L("%d following, %d followers"), following_list_len(user), follower_list_len(user));
1170 xs *fwing = following_list(user);
1171
1172 xs *s1 = xs_fmt(L("%d following, %d followers"),
1173 xs_list_len(fwing), xs_list_len(fwers));
1174 1156
1175 xs_html_add(top_user, 1157 xs_html_add(top_user,
1176 xs_html_tag("p", 1158 xs_html_tag("p",
@@ -1951,6 +1933,15 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
1951 return xs_html_tag("mark", 1933 return xs_html_tag("mark",
1952 xs_html_text(L("Truncated (too deep)"))); 1934 xs_html_text(L("Truncated (too deep)")));
1953 1935
1936 const char *lang = NULL;
1937 const xs_dict *cmap = xs_dict_get(msg, "contentMap");
1938 if (xs_is_dict(cmap)) {
1939 const char *dummy;
1940 int c = 0;
1941
1942 xs_dict_next(cmap, &lang, &dummy, &c);
1943 }
1944
1954 if (strcmp(type, "Follow") == 0) { 1945 if (strcmp(type, "Follow") == 0) {
1955 return xs_html_tag("div", 1946 return xs_html_tag("div",
1956 xs_html_attr("class", "snac-post"), 1947 xs_html_attr("class", "snac-post"),
@@ -1959,7 +1950,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
1959 xs_html_tag("div", 1950 xs_html_tag("div",
1960 xs_html_attr("class", "snac-origin"), 1951 xs_html_attr("class", "snac-origin"),
1961 xs_html_text(L("follows you"))), 1952 xs_html_text(L("follows you"))),
1962 html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy, NULL))); 1953 html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy, NULL, lang)));
1963 } 1954 }
1964 else 1955 else
1965 if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { 1956 if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) {
@@ -2140,13 +2131,17 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2140 } 2131 }
2141 2132
2142 xs_html_add(post_header, 2133 xs_html_add(post_header,
2143 html_msg_icon(read_only ? NULL : user, actor, msg, proxy, md5)); 2134 html_msg_icon(read_only ? NULL : user, actor, msg, proxy, md5, lang));
2144 2135
2145 /** post content **/ 2136 /** post content **/
2146 2137
2147 xs_html *snac_content_wrap = xs_html_tag("div", 2138 xs_html *snac_content_wrap = xs_html_tag("div",
2148 xs_html_attr("class", "e-content snac-content")); 2139 xs_html_attr("class", "e-content snac-content"));
2149 2140
2141 if (xs_is_string(lang))
2142 xs_html_add(snac_content_wrap,
2143 xs_html_attr("lang", lang));
2144
2150 xs_html_add(entry, 2145 xs_html_add(entry,
2151 snac_content_wrap); 2146 snac_content_wrap);
2152 2147
diff --git a/mastoapi.c b/mastoapi.c
index 0348ec6..c46a971 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -681,10 +681,10 @@ xs_dict *mastoapi_account(snac *logged, const xs_dict *actor)
681 681
682 /* does this user want to publish their contact metrics? */ 682 /* does this user want to publish their contact metrics? */
683 if (xs_is_true(xs_dict_get(user.config, "show_contact_metrics"))) { 683 if (xs_is_true(xs_dict_get(user.config, "show_contact_metrics"))) {
684 xs *fwing = following_list(&user); 684 int fwing = following_list_len(&user);
685 xs *fwers = follower_list(&user); 685 int fwers = follower_list_len(&user);
686 xs *ni = xs_number_new(xs_list_len(fwing)); 686 xs *ni = xs_number_new(fwing);
687 xs *ne = xs_number_new(xs_list_len(fwers)); 687 xs *ne = xs_number_new(fwers);
688 688
689 acct = xs_dict_append(acct, "followers_count", ne); 689 acct = xs_dict_append(acct, "followers_count", ne);
690 acct = xs_dict_append(acct, "following_count", ni); 690 acct = xs_dict_append(acct, "following_count", ni);
@@ -1310,10 +1310,10 @@ void credentials_get(char **body, char **ctype, int *status, snac snac)
1310 1310
1311 /* does this user want to publish their contact metrics? */ 1311 /* does this user want to publish their contact metrics? */
1312 if (xs_is_true(xs_dict_get(snac.config, "show_contact_metrics"))) { 1312 if (xs_is_true(xs_dict_get(snac.config, "show_contact_metrics"))) {
1313 xs *fwing = following_list(&snac); 1313 int fwing = following_list_len(&snac);
1314 xs *fwers = follower_list(&snac); 1314 int fwers = follower_list_len(&snac);
1315 xs *ni = xs_number_new(xs_list_len(fwing)); 1315 xs *ni = xs_number_new(fwing);
1316 xs *ne = xs_number_new(xs_list_len(fwers)); 1316 xs *ne = xs_number_new(fwers);
1317 1317
1318 acct = xs_dict_append(acct, "followers_count", ne); 1318 acct = xs_dict_append(acct, "followers_count", ne);
1319 acct = xs_dict_append(acct, "following_count", ni); 1319 acct = xs_dict_append(acct, "following_count", ni);
diff --git a/po/de_DE.po b/po/de_DE.po
index 39fc03e..9f96530 100644
--- a/po/de_DE.po
+++ b/po/de_DE.po
@@ -750,7 +750,7 @@ msgstr "Geplante Beiträge"
750 750
751#: html.c:2928 751#: html.c:2928
752msgid "scheduled posts" 752msgid "scheduled posts"
753msgstr "geplante Beiträge" 753msgstr "Geplante Beiträge"
754 754
755#: html.c:458 755#: html.c:458
756#, c-format 756#, c-format
diff --git a/po/ru.po b/po/ru.po
index 4d5d9b4..f95b0d1 100644
--- a/po/ru.po
+++ b/po/ru.po
@@ -126,7 +126,7 @@ msgstr "люди"
126 126
127#: html.c:936 127#: html.c:936
128msgid "instance" 128msgid "instance"
129msgstr "зл" 129msgstr "ерр"
130 130
131#: html.c:945 131#: html.c:945
132msgid "" 132msgid ""
@@ -679,12 +679,12 @@ msgstr "Ничего не найдено для '%s'"
679 679
680#: html.c:3929 680#: html.c:3929
681msgid "Showing instance timeline" 681msgid "Showing instance timeline"
682msgstr "Показываем ленту инси" 682msgstr "Показываем ленту се"
683 683
684#: html.c:4012 684#: html.c:4012
685#, c-format 685#, c-format
686msgid "Showing timeline for list '%s'" 686msgid "Showing timeline for list '%s'"
687msgstr "Показываем лент нстанции ля списка '%s'" 687msgstr "Показываем лент для списка '%s'"
688 688
689#: httpd.c:250 689#: httpd.c:250
690#, c-format 690#, c-format
@@ -693,7 +693,7 @@ msgstr "Результаты поиска для тега #%s"
693 693
694#: httpd.c:259 694#: httpd.c:259
695msgid "Recent posts by users in this instance" 695msgid "Recent posts by users in this instance"
696msgstr "Последние сообщения на это инси" 696msgstr "Последние сообщения на это се"
697 697
698#: html.c:1603 698#: html.c:1603
699msgid "Blocked hashtags..." 699msgid "Blocked hashtags..."
diff --git a/snac.h b/snac.h
index 2ab9a67..256731f 100644
--- a/snac.h
+++ b/snac.h
@@ -153,6 +153,7 @@ int follower_add(snac *snac, const char *actor);
153int follower_del(snac *snac, const char *actor); 153int follower_del(snac *snac, const char *actor);
154int follower_check(snac *snac, const char *actor); 154int follower_check(snac *snac, const char *actor);
155xs_list *follower_list(snac *snac); 155xs_list *follower_list(snac *snac);
156int follower_list_len(snac *snac);
156 157
157int pending_add(snac *user, const char *actor, const xs_dict *msg); 158int pending_add(snac *user, const char *actor, const xs_dict *msg);
158int pending_check(snac *user, const char *actor); 159int pending_check(snac *user, const char *actor);
@@ -184,6 +185,7 @@ int following_del(snac *snac, const char *actor);
184int following_check(snac *snac, const char *actor); 185int following_check(snac *snac, const char *actor);
185int following_get(snac *snac, const char *actor, xs_dict **data); 186int following_get(snac *snac, const char *actor, xs_dict **data);
186xs_list *following_list(snac *snac); 187xs_list *following_list(snac *snac);
188int following_list_len(snac *snac);
187 189
188void mute(snac *snac, const char *actor); 190void mute(snac *snac, const char *actor);
189void unmute(snac *snac, const char *actor); 191void unmute(snac *snac, const char *actor);
diff --git a/utils.c b/utils.c
index 576b17c..d50707a 100644
--- a/utils.c
+++ b/utils.c
@@ -101,8 +101,9 @@ static const char *greeting_html =
101 "<html><head>\n" 101 "<html><head>\n"
102 "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n" 102 "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n"
103 "<link rel=\"icon\" type=\"image/x-icon\" href=\"https://%host%/favicon.ico\"/>\n" 103 "<link rel=\"icon\" type=\"image/x-icon\" href=\"https://%host%/favicon.ico\"/>\n"
104 "<style>*{color-scheme:light dark}body{margin:auto;max-width:50em}</style>\n"
104 "<title>Welcome to %host%</title>\n</head>\n" 105 "<title>Welcome to %host%</title>\n</head>\n"
105 "<body style=\"margin: auto; max-width: 50em\">\n" 106 "<body>\n"
106 "%blurb%" 107 "%blurb%"
107 "<p>The following users are part of this community:</p>\n" 108 "<p>The following users are part of this community:</p>\n"
108 "\n" 109 "\n"