From d2095105de3fe8c3397df7d46a9d61011b74c09e Mon Sep 17 00:00:00 2001 From: default Date: Mon, 24 Oct 2022 20:06:02 +0200 Subject: [PATCH] Don't load unneeded actor info in html_entry(). --- data.c | 13 +++++++------ html.c | 6 +----- httpd.c | 16 ++++++++-------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/data.c b/data.c index 7b623af..4771190 100644 --- a/data.c +++ b/data.c @@ -796,16 +796,17 @@ int actor_get(snac *snac, char *actor, d_char **data) status = 200; } - if ((f = fopen(fn, "r")) != NULL) { - xs *j = xs_readall(f); + if (data) { + if ((f = fopen(fn, "r")) != NULL) { + xs *j = xs_readall(f); - fclose(f); + fclose(f); - if (data) *data = xs_json_loads(j); + } + else + status = 500; } - else - status = 500; return status; } diff --git a/html.c b/html.c index 9cf0815..bc84d07 100644 --- a/html.c +++ b/html.c @@ -443,7 +443,6 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i char *id = xs_dict_get(msg, "id"); char *type = xs_dict_get(msg, "type"); char *meta = xs_dict_get(msg, "_snac"); - xs *actor_o = NULL; char *actor; /* do not show non-public messages in the public timeline */ @@ -477,10 +476,7 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i if (is_muted(snac, actor)) return os; - if (strcmp(actor, snac->actor) == 0) - actor_o = msg_actor(snac); - else - if (!valid_status(actor_get(snac, actor, &actor_o))) + if (strcmp(actor, snac->actor) != 0 && !valid_status(actor_get(snac, actor, NULL))) return os; /* if this is our post, add the score */ diff --git a/httpd.c b/httpd.c index a365b4d..d7fad93 100644 --- a/httpd.c +++ b/httpd.c @@ -98,14 +98,14 @@ void httpd_connection(FILE *f) { xs *req; char *method; - int status = 0; - char *body = NULL; - int b_size = 0; - char *ctype = NULL; - xs *headers = NULL; - xs *q_path = NULL; - xs *payload = NULL; - int p_size = 0; + int status = 0; + d_char *body = NULL; + int b_size = 0; + char *ctype = NULL; + xs *headers = NULL; + xs *q_path = NULL; + xs *payload = NULL; + int p_size = 0; char *p; req = xs_httpd_request(f, &payload, &p_size);