commit 850259b

default  ·  2022-12-23 20:41:52 +0000 UTC
parent e762d94
Added a working space to timeline_request().
1 files changed,  +13, -9
+13, -9
 1@@ -78,7 +78,7 @@ int actor_request(snac *snac, char *actor, d_char **data)
 2 }
 3 
 4 
 5-int timeline_request(snac *snac, char **id, char *referrer)
 6+int timeline_request(snac *snac, char **id, char *referrer, d_char **wrk)
 7 /* ensures that an entry and its ancestors are in the timeline */
 8 {
 9     int status = 0;
10@@ -97,12 +97,12 @@ int timeline_request(snac *snac, char **id, char *referrer)
11                 /* get the id again from the object, as it may be different */
12                 char *nid = xs_dict_get(object, "id");
13 
14-                if (strcmp(nid, *id) != 0) {
15+                if (wrk && strcmp(nid, *id) != 0) {
16                     snac_debug(snac, 1,
17                         xs_fmt("timeline_request canonical id for %s is %s", *id, nid));
18 
19-                    /* FIXME: nid points inside a dynamic block */
20-                    *id = nid;
21+                    *wrk = xs_dup(nid);
22+                    *id  = *wrk;
23                 }
24 
25                 if (!xs_is_null(type) && strcmp(type, "Note") == 0) {
26@@ -116,7 +116,7 @@ int timeline_request(snac *snac, char **id, char *referrer)
27                     char *in_reply_to = xs_dict_get(object, "inReplyTo");
28 
29                     /* recurse! */
30-                    timeline_request(snac, &in_reply_to, referrer);
31+                    timeline_request(snac, &in_reply_to, referrer, NULL);
32 
33                     /* finally store */
34                     timeline_add(snac, *id, object, in_reply_to, referrer);
35@@ -419,9 +419,10 @@ d_char *msg_admiration(snac *snac, char *object, char *type)
36 {
37     xs *a_msg   = NULL;
38     d_char *msg = NULL;
39+    xs *wrk     = NULL;
40 
41     /* call the object */
42-    timeline_request(snac, &object, snac->actor);
43+    timeline_request(snac, &object, snac->actor, &wrk);
44 
45     if (valid_status(object_get(object, &a_msg, NULL))) {
46         xs *rcpts = xs_list_new();
47@@ -612,9 +613,10 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char
48 
49     if (in_reply_to != NULL && *in_reply_to) {
50         xs *p_msg = NULL;
51+        xs *wrk   = NULL;
52 
53         /* demand this thing */
54-        timeline_request(snac, &in_reply_to, NULL);
55+        timeline_request(snac, &in_reply_to, NULL, &wrk);
56 
57         if (valid_status(object_get(in_reply_to, &p_msg, NULL))) {
58             /* add this author as recipient */
59@@ -886,8 +888,9 @@ int process_message(snac *snac, char *msg, char *req)
60             else {
61                 char *id          = xs_dict_get(object, "id");
62                 char *in_reply_to = xs_dict_get(object, "inReplyTo");
63+                xs *wrk           = NULL;
64 
65-                timeline_request(snac, &in_reply_to, NULL);
66+                timeline_request(snac, &in_reply_to, NULL, &wrk);
67 
68                 if (timeline_add(snac, id, object, in_reply_to, NULL)) {
69                     snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id));
70@@ -923,11 +926,12 @@ int process_message(snac *snac, char *msg, char *req)
71     else
72     if (strcmp(type, "Announce") == 0) {
73         xs *a_msg = NULL;
74+        xs *wrk   = NULL;
75 
76         if (xs_type(object) == XSTYPE_DICT)
77             object = xs_dict_get(object, "id");
78 
79-        timeline_request(snac, &object, actor);
80+        timeline_request(snac, &object, actor, &wrk);
81 
82         if (valid_status(object_get(object, &a_msg, NULL))) {
83             char *who = xs_dict_get(a_msg, "attributedTo");