commit b64bebd
Alexandre Oliva
·
2025-12-28 19:59:12 +0000 UTC
parent 3f8bd3e
introduce separate people/ pages When you have lots of followers or followees or pending follows, constructing the entire people page to look up information about a single user can take a while and be quite wasteful when you want to look up a single user. Introduce and prefer people/<md5> over people#<md5>. While at that, fix a memory leak in webfinger search: the empty list was allocated twice.
2 files changed,
+52,
-3
+2,
-0
1@@ -2,6 +2,8 @@
2
3 ## UNRELEASED
4
5+Link contacts to single-user people pages (contributed by lxo).
6+
7 Added emoji reactions (contributed by violette).
8
9 Mastodon API: Fix for some client notifications (contributed by violette), fix for a status visibility error (contributed by fruye).
M
html.c
+50,
-3
1@@ -221,7 +221,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
2 anchored link to the people page instead of the actor url */
3 if (fwer || fwing) {
4 xs *md5 = xs_md5_hex(actor_id, strlen(actor_id));
5- href = xs_fmt("%s/people#%s", user->actor, md5);
6+ href = xs_fmt("%s/people/%s", user->actor, md5);
7 }
8 }
9
10@@ -2355,7 +2355,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
11 }
12
13 if (!read_only && (fwers || fwing))
14- href = xs_fmt("%s/people#%s", user->actor, p);
15+ href = xs_fmt("%s/people/%s", user->actor, p);
16 else
17 href = xs_dup(id);
18
19@@ -3856,6 +3856,29 @@ xs_str *html_people(snac *user)
20 return xs_html_render_s(html, "<!DOCTYPE html>\n");
21 }
22
23+xs_str *html_people_one(snac *user, const char *actor)
24+{
25+ const char *proxy = NULL;
26+
27+ if (xs_is_true(xs_dict_get(srv_config, "proxy_media")))
28+ proxy = user->actor;
29+
30+ xs_html *lists = xs_html_tag("div",
31+ xs_html_attr("class", "snac-posts"));
32+
33+ xs *foll = xs_list_append(xs_list_new(), actor);
34+
35+ xs_html_add(lists,
36+ html_people_list(user, foll, L("People - single"), "p", proxy));
37+
38+ xs_html *html = xs_html_tag("html",
39+ html_user_head(user, NULL, NULL),
40+ xs_html_add(html_user_body(user, 0),
41+ lists,
42+ html_footer(user)));
43+
44+ return xs_html_render_s(html, "<!DOCTYPE html>\n");
45+}
46
47 xs_str *html_notifications(snac *user, int skip, int show)
48 {
49@@ -4415,7 +4438,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
50 actor_add(actor, actor_obj);
51
52 /* create a people list with only one element */
53- l = xs_list_append(xs_list_new(), actor);
54+ l = xs_list_append(l, actor);
55
56 xs *title = xs_fmt(L("Search results for account %s"), q);
57
58@@ -4555,6 +4578,30 @@ int html_get_handler(const xs_dict *req, const char *q_path,
59 }
60 }
61 else
62+ if (xs_startswith(p_path, "people/")) { /** the list of people **/
63+ if (!login(&snac, req)) {
64+ *body = xs_dup(uid);
65+ status = HTTP_STATUS_UNAUTHORIZED;
66+ }
67+ else {
68+ xs *actor_dict = NULL;
69+ const char *actor_id = NULL;
70+ xs *actor = NULL;
71+
72+ if (valid_status(object_get_by_md5(p_path + strlen("people/"), &actor_dict)) &&
73+ (actor_id = xs_dict_get(actor_dict, "id")) != NULL &&
74+ valid_status(actor_get(actor_id, &actor))) {
75+ *body = html_people_one(&snac, actor_id);
76+ *b_size = strlen(*body);
77+ status = HTTP_STATUS_OK;
78+ }
79+ else {
80+ *body = xs_dup(uid);
81+ status = HTTP_STATUS_NOT_FOUND;
82+ }
83+ }
84+ }
85+ else
86 if (strcmp(p_path, "notifications") == 0) { /** the list of notifications **/
87 if (!login(&snac, req)) {
88 *body = xs_dup(uid);