summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar Alexandre Oliva2025-12-28 20:59:12 +0100
committerGravatar grunfink2025-12-28 20:59:12 +0100
commitb64bebd412f10e7a29f92220624e8423aaf5d883 (patch)
tree5794577efa5e76b49c528a004ad101897e446f8e /html.c
parentMerge pull request 'Update pt_BR translation' (#511) from daltux/snac2:pt_BR-... (diff)
downloadsnac2-b64bebd412f10e7a29f92220624e8423aaf5d883.tar.gz
snac2-b64bebd412f10e7a29f92220624e8423aaf5d883.tar.xz
snac2-b64bebd412f10e7a29f92220624e8423aaf5d883.zip
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.
Diffstat (limited to 'html.c')
-rw-r--r--html.c53
1 files changed, 50 insertions, 3 deletions
diff --git a/html.c b/html.c
index 3e692bd..c03c867 100644
--- a/html.c
+++ b/html.c
@@ -221,7 +221,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
221 anchored link to the people page instead of the actor url */ 221 anchored link to the people page instead of the actor url */
222 if (fwer || fwing) { 222 if (fwer || fwing) {
223 xs *md5 = xs_md5_hex(actor_id, strlen(actor_id)); 223 xs *md5 = xs_md5_hex(actor_id, strlen(actor_id));
224 href = xs_fmt("%s/people#%s", user->actor, md5); 224 href = xs_fmt("%s/people/%s", user->actor, md5);
225 } 225 }
226 } 226 }
227 227
@@ -2355,7 +2355,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2355 } 2355 }
2356 2356
2357 if (!read_only && (fwers || fwing)) 2357 if (!read_only && (fwers || fwing))
2358 href = xs_fmt("%s/people#%s", user->actor, p); 2358 href = xs_fmt("%s/people/%s", user->actor, p);
2359 else 2359 else
2360 href = xs_dup(id); 2360 href = xs_dup(id);
2361 2361
@@ -3856,6 +3856,29 @@ xs_str *html_people(snac *user)
3856 return xs_html_render_s(html, "<!DOCTYPE html>\n"); 3856 return xs_html_render_s(html, "<!DOCTYPE html>\n");
3857} 3857}
3858 3858
3859xs_str *html_people_one(snac *user, const char *actor)
3860{
3861 const char *proxy = NULL;
3862
3863 if (xs_is_true(xs_dict_get(srv_config, "proxy_media")))
3864 proxy = user->actor;
3865
3866 xs_html *lists = xs_html_tag("div",
3867 xs_html_attr("class", "snac-posts"));
3868
3869 xs *foll = xs_list_append(xs_list_new(), actor);
3870
3871 xs_html_add(lists,
3872 html_people_list(user, foll, L("People - single"), "p", proxy));
3873
3874 xs_html *html = xs_html_tag("html",
3875 html_user_head(user, NULL, NULL),
3876 xs_html_add(html_user_body(user, 0),
3877 lists,
3878 html_footer(user)));
3879
3880 return xs_html_render_s(html, "<!DOCTYPE html>\n");
3881}
3859 3882
3860xs_str *html_notifications(snac *user, int skip, int show) 3883xs_str *html_notifications(snac *user, int skip, int show)
3861{ 3884{
@@ -4415,7 +4438,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
4415 actor_add(actor, actor_obj); 4438 actor_add(actor, actor_obj);
4416 4439
4417 /* create a people list with only one element */ 4440 /* create a people list with only one element */
4418 l = xs_list_append(xs_list_new(), actor); 4441 l = xs_list_append(l, actor);
4419 4442
4420 xs *title = xs_fmt(L("Search results for account %s"), q); 4443 xs *title = xs_fmt(L("Search results for account %s"), q);
4421 4444
@@ -4555,6 +4578,30 @@ int html_get_handler(const xs_dict *req, const char *q_path,
4555 } 4578 }
4556 } 4579 }
4557 else 4580 else
4581 if (xs_startswith(p_path, "people/")) { /** the list of people **/
4582 if (!login(&snac, req)) {
4583 *body = xs_dup(uid);
4584 status = HTTP_STATUS_UNAUTHORIZED;
4585 }
4586 else {
4587 xs *actor_dict = NULL;
4588 const char *actor_id = NULL;
4589 xs *actor = NULL;
4590
4591 if (valid_status(object_get_by_md5(p_path + strlen("people/"), &actor_dict)) &&
4592 (actor_id = xs_dict_get(actor_dict, "id")) != NULL &&
4593 valid_status(actor_get(actor_id, &actor))) {
4594 *body = html_people_one(&snac, actor_id);
4595 *b_size = strlen(*body);
4596 status = HTTP_STATUS_OK;
4597 }
4598 else {
4599 *body = xs_dup(uid);
4600 status = HTTP_STATUS_NOT_FOUND;
4601 }
4602 }
4603 }
4604 else
4558 if (strcmp(p_path, "notifications") == 0) { /** the list of notifications **/ 4605 if (strcmp(p_path, "notifications") == 0) { /** the list of notifications **/
4559 if (!login(&snac, req)) { 4606 if (!login(&snac, req)) {
4560 *body = xs_dup(uid); 4607 *body = xs_dup(uid);