Sfoglia il codice sorgente

Show stray parents in the origin.

default 3 anni fa
parent
commit
2614a8b3cb
2 ha cambiato i file con 14 aggiunte e 22 eliminazioni
  1. 12 22
      html.c
  2. 2 0
      snac.h

+ 12 - 22
html.c

@@ -591,31 +591,21 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int
                 }
             }
         }
-
-#if 0
-        if (!xs_is_null((p = xs_dict_get(meta, "parent"))) && *p) {
-            /* this may happen if any of the autor or the parent aren't here */
-            xs *s1 = xs_fmt(
-                "<div class=\"snac-origin\">%s "
-                "<a href=\"%s\">»</a></div>\n",
-                L("in reply to"), p
-            );
-
-            s = xs_str_cat(s, s1);
-        }
         else
-        if (!xs_is_null((p = xs_dict_get(meta, "liked_by"))) &&
-            xs_list_in(p, snac->actor) != -1) {
-            /* we liked this */
-            xs *s1 = xs_fmt(
-                "<div class=\"snac-origin\">"
-                "<a href=\"%s\">%s</a> %s</a></div>",
-                snac->actor, xs_dict_get(snac->config, "name"), L("liked")
-            );
+        if (strcmp(type, "Note") == 0) {
+            /* is the parent not here? */
+            char *parent = xs_dict_get(msg, "inReplyTo");
 
-            s = xs_str_cat(s, s1);
+            if (!xs_is_null(parent) && !object_here(parent)) {
+                xs *s1 = xs_fmt(
+                    "<div class=\"snac-origin\">%s "
+                    "<a href=\"%s\">»</a></div>\n",
+                    L("in reply to"), parent
+                );
+
+                s = xs_str_cat(s, s1);
+            }
         }
-#endif
     }
     else
         s = xs_str_cat(s, "<div class=\"snac-child\">\n");

+ 2 - 0
snac.h

@@ -60,6 +60,7 @@ int index_first(const char *fn, char *buf, int size);
 d_char *index_list(const char *fn, int max);
 d_char *index_list_desc(const char *fn, int max);
 
+int object_here_by_md5(char *id);
 int object_here(char *id);
 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);
@@ -69,6 +70,7 @@ int object_del_if_unref(const char *id);
 d_char *object_children(const char *id);
 d_char *object_likes(const char *id);
 d_char *object_announces(const char *id);
+int object_parent(const char *id, char *buf, int size);
 
 int follower_add(snac *snac, const char *actor);
 int follower_del(snac *snac, const char *actor);