浏览代码

Fixed one post queries.

default 3 年之前
父节点
当前提交
c06136a8ac
共有 3 个文件被更改,包括 8 次插入8 次删除
  1. 1 4
      activitypub.c
  2. 6 4
      html.c
  3. 1 0
      snac.h

+ 1 - 4
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;

+ 6 - 4
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);

+ 1 - 0
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);