From c06136a8ac480a2ff350f751ddc710c3a5f264c3 Mon Sep 17 00:00:00 2001 From: default Date: Fri, 2 Dec 2022 19:39:17 +0100 Subject: [PATCH] Fixed one post queries. --- activitypub.c | 5 +---- html.c | 10 ++++++---- snac.h | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/activitypub.c b/activitypub.c index 8a5dd3c..764f69d 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1128,10 +1128,7 @@ int activitypub_get_handler(d_char *req, char *q_path, if (xs_startswith(p_path, "p/")) { xs *id = xs_fmt("%s/%s", snac.actor, p_path); - if ((msg = timeline_find(&snac, id)) != NULL) - msg = xs_dict_del(msg, "_snac"); - else - status = 404; + status = object_get(id, &msg, NULL); } else status = 404; diff --git a/html.c b/html.c index f7766e6..d486139 100644 --- a/html.c +++ b/html.c @@ -1066,12 +1066,14 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char * else if (xs_startswith(p_path, "p/")) { /* a timeline with just one entry */ - xs *id = xs_fmt("%s/%s", snac.actor, p_path); - xs *fn = _timeline_find_fn(&snac, id); + xs *id = xs_fmt("%s/%s", snac.actor, p_path); + xs *msg = NULL; - if (fn != NULL) { + if (valid_status(object_get(id, &msg, NULL))) { + xs *md5 = xs_md5_hex(id, strlen(id)); xs *list = xs_list_new(); - list = xs_list_append(list, fn); + + list = xs_list_append(list, md5); *body = html_timeline(&snac, list, 1); *b_size = strlen(*body); diff --git a/snac.h b/snac.h index 88f335a..91e745e 100644 --- a/snac.h +++ b/snac.h @@ -61,6 +61,7 @@ d_char *index_list(const char *fn, int max); d_char *index_list_desc(const char *fn, int max); int object_get_by_md5(const char *md5, d_char **obj, const char *type); +int object_get(const char *id, d_char **obj, const char *type); int object_del(const char *id); int object_del_if_unref(const char *id);