commit 2614a8b

default  ·  2022-12-02 20:36:12 +0000 UTC
parent adfc921
Show stray parents in the origin.
2 files changed,  +14, -22
M html.c
M snac.h
M html.c
+12, -22
 1@@ -591,31 +591,21 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int
 2                 }
 3             }
 4         }
 5-
 6-#if 0
 7-        if (!xs_is_null((p = xs_dict_get(meta, "parent"))) && *p) {
 8-            /* this may happen if any of the autor or the parent aren't here */
 9-            xs *s1 = xs_fmt(
10-                "<div class=\"snac-origin\">%s "
11-                "<a href=\"%s\">»</a></div>\n",
12-                L("in reply to"), p
13-            );
14-
15-            s = xs_str_cat(s, s1);
16-        }
17         else
18-        if (!xs_is_null((p = xs_dict_get(meta, "liked_by"))) &&
19-            xs_list_in(p, snac->actor) != -1) {
20-            /* we liked this */
21-            xs *s1 = xs_fmt(
22-                "<div class=\"snac-origin\">"
23-                "<a href=\"%s\">%s</a> %s</a></div>",
24-                snac->actor, xs_dict_get(snac->config, "name"), L("liked")
25-            );
26+        if (strcmp(type, "Note") == 0) {
27+            /* is the parent not here? */
28+            char *parent = xs_dict_get(msg, "inReplyTo");
29 
30-            s = xs_str_cat(s, s1);
31+            if (!xs_is_null(parent) && !object_here(parent)) {
32+                xs *s1 = xs_fmt(
33+                    "<div class=\"snac-origin\">%s "
34+                    "<a href=\"%s\">»</a></div>\n",
35+                    L("in reply to"), parent
36+                );
37+
38+                s = xs_str_cat(s, s1);
39+            }
40         }
41-#endif
42     }
43     else
44         s = xs_str_cat(s, "<div class=\"snac-child\">\n");
M snac.h
+2, -0
 1@@ -60,6 +60,7 @@ int index_first(const char *fn, char *buf, int size);
 2 d_char *index_list(const char *fn, int max);
 3 d_char *index_list_desc(const char *fn, int max);
 4 
 5+int object_here_by_md5(char *id);
 6 int object_here(char *id);
 7 int object_get_by_md5(const char *md5, d_char **obj, const char *type);
 8 int object_get(const char *id, d_char **obj, const char *type);
 9@@ -69,6 +70,7 @@ int object_del_if_unref(const char *id);
10 d_char *object_children(const char *id);
11 d_char *object_likes(const char *id);
12 d_char *object_announces(const char *id);
13+int object_parent(const char *id, char *buf, int size);
14 
15 int follower_add(snac *snac, const char *actor);
16 int follower_del(snac *snac, const char *actor);