commit 085caa7

default  ·  2024-11-19 05:46:14 +0000 UTC
parent 4daacf6
New function get_in_reply_to().
4 files changed,  +19, -6
M html.c
M snac.h
+15, -3
 1@@ -183,6 +183,18 @@ const char *get_atto(const xs_dict *msg)
 2 }
 3 
 4 
 5+const char *get_in_reply_to(const xs_dict *msg)
 6+/* gets the inReplyTo id */
 7+{
 8+    const xs_val *in_reply_to = xs_dict_get(msg, "inReplyTo");
 9+
10+    if (xs_type(in_reply_to) == XSTYPE_DICT)
11+        in_reply_to = xs_dict_get(in_reply_to, "id");
12+
13+    return in_reply_to;
14+}
15+
16+
17 xs_list *get_attachments(const xs_dict *msg)
18 /* unify the garbage fire that are the attachments */
19 {
20@@ -373,7 +385,7 @@ int timeline_request(snac *snac, const char **id, xs_str **wrk, int level)
21                             }
22 
23                             /* does it have an ancestor? */
24-                            const char *in_reply_to = xs_dict_get(object, "inReplyTo");
25+                            const char *in_reply_to = get_in_reply_to(object);
26 
27                             /* store */
28                             timeline_add(snac, nid, object);
29@@ -671,7 +683,7 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg)
30         return 3;
31 
32     /* is this message a reply to another? */
33-    const char *irt = xs_dict_get(msg, "inReplyTo");
34+    const char *irt = get_in_reply_to(msg);
35     if (!xs_is_null(irt)) {
36         xs *r_msg = NULL;
37 
38@@ -1957,7 +1969,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
39 
40         if (xs_match(utype, "Note|Article")) { /** **/
41             const char *id          = xs_dict_get(object, "id");
42-            const char *in_reply_to = xs_dict_get(object, "inReplyTo");
43+            const char *in_reply_to = get_in_reply_to(object);
44             const char *atto        = get_atto(object);
45             xs *wrk           = NULL;
46 
M html.c
+2, -2
 1@@ -1670,7 +1670,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
 2     if (strcmp(type, "Note") == 0) {
 3         if (level == 0) {
 4             /* is the parent not here? */
 5-            const char *parent = xs_dict_get(msg, "inReplyTo");
 6+            const char *parent = get_in_reply_to(msg);
 7 
 8             if (user && !xs_is_null(parent) && *parent && !timeline_here(user, parent)) {
 9                 xs_html_add(post_header,
10@@ -2329,7 +2329,7 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only,
11 
12         /* is this message a non-public reply? */
13         if (user != NULL && !is_msg_public(msg)) {
14-            const char *irt = xs_dict_get(msg, "inReplyTo");
15+            const char *irt = get_in_reply_to(msg);
16 
17             /* is it a reply to something not in the storage? */
18             if (!xs_is_null(irt) && !object_here(irt)) {
+1, -1
1@@ -1024,7 +1024,7 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
2     st = xs_dict_append(st, "in_reply_to_id",         xs_stock(XSTYPE_NULL));
3     st = xs_dict_append(st, "in_reply_to_account_id", xs_stock(XSTYPE_NULL));
4 
5-    tmp = xs_dict_get(msg, "inReplyTo");
6+    tmp = get_in_reply_to(msg);
7     if (!xs_is_null(tmp)) {
8         xs *irto = NULL;
9 
M snac.h
+1, -0
1@@ -296,6 +296,7 @@ const char *default_avatar_base64(void);
2 xs_str *process_tags(snac *snac, const char *content, xs_list **tag);
3 
4 const char *get_atto(const xs_dict *msg);
5+const char *get_in_reply_to(const xs_dict *msg);
6 xs_list *get_attachments(const xs_dict *msg);
7 
8 xs_dict *msg_admiration(snac *snac, const char *object, const char *type);