commit c06136a

default  ·  2022-12-02 18:39:17 +0000 UTC
parent 33c8a73
Fixed one post queries.
3 files changed,  +8, -8
M html.c
M snac.h
+1, -4
 1@@ -1128,10 +1128,7 @@ int activitypub_get_handler(d_char *req, char *q_path,
 2     if (xs_startswith(p_path, "p/")) {
 3         xs *id = xs_fmt("%s/%s", snac.actor, p_path);
 4 
 5-        if ((msg = timeline_find(&snac, id)) != NULL)
 6-            msg = xs_dict_del(msg, "_snac");
 7-        else
 8-            status = 404;
 9+        status = object_get(id, &msg, NULL);
10     }
11     else
12         status = 404;
M html.c
+6, -4
 1@@ -1066,12 +1066,14 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
 2     else
 3     if (xs_startswith(p_path, "p/")) {
 4         /* a timeline with just one entry */
 5-        xs *id = xs_fmt("%s/%s", snac.actor, p_path);
 6-        xs *fn = _timeline_find_fn(&snac, id);
 7+        xs *id  = xs_fmt("%s/%s", snac.actor, p_path);
 8+        xs *msg = NULL;
 9 
10-        if (fn != NULL) {
11+        if (valid_status(object_get(id, &msg, NULL))) {
12+            xs *md5  = xs_md5_hex(id, strlen(id));
13             xs *list = xs_list_new();
14-            list = xs_list_append(list, fn);
15+
16+            list = xs_list_append(list, md5);
17 
18             *body   = html_timeline(&snac, list, 1);
19             *b_size = strlen(*body);
M snac.h
+1, -0
1@@ -61,6 +61,7 @@ d_char *index_list(const char *fn, int max);
2 d_char *index_list_desc(const char *fn, int max);
3 
4 int object_get_by_md5(const char *md5, d_char **obj, const char *type);
5+int object_get(const char *id, d_char **obj, const char *type);
6 int object_del(const char *id);
7 int object_del_if_unref(const char *id);
8