commit a05aa96
default
·
2023-07-13 18:19:50 +0000 UTC
parent 0bdd1f0
Added a maximum level of recursion to timeline_request().
1 files changed,
+8,
-7
+8,
-7
1@@ -146,7 +146,7 @@ int actor_request(snac *snac, const char *actor, xs_dict **data)
2 }
3
4
5-int timeline_request(snac *snac, char **id, xs_str **wrk)
6+int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
7 /* ensures that an entry and its ancestors are in the timeline */
8 {
9 int status = 0;
10@@ -187,7 +187,8 @@ int timeline_request(snac *snac, char **id, xs_str **wrk)
11 timeline_add(snac, *id, object);
12
13 /* recurse! */
14- timeline_request(snac, &in_reply_to, NULL);
15+ if (level < 32)
16+ timeline_request(snac, &in_reply_to, NULL, level + 1);
17 }
18 }
19 }
20@@ -255,7 +256,7 @@ void timeline_request_replies(snac *user, const char *id)
21 }
22 else {
23 snac_debug(user, 0, xs_fmt("request reply %s", v));
24- timeline_request(user, &v, NULL);
25+ timeline_request(user, &v, NULL, 0);
26 }
27 }
28 }
29@@ -830,7 +831,7 @@ xs_dict *msg_admiration(snac *snac, char *object, char *type)
30 xs *wrk = NULL;
31
32 /* call the object */
33- timeline_request(snac, &object, &wrk);
34+ timeline_request(snac, &object, &wrk, 0);
35
36 if (valid_status(object_get(object, &a_msg))) {
37 xs *rcpts = xs_list_new();
38@@ -1039,7 +1040,7 @@ xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts,
39 xs *wrk = NULL;
40
41 /* demand this thing */
42- timeline_request(snac, &in_reply_to, &wrk);
43+ timeline_request(snac, &in_reply_to, &wrk, 0);
44
45 if (valid_status(object_get(in_reply_to, &p_msg))) {
46 /* add this author as recipient */
47@@ -1468,7 +1469,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
48 char *in_reply_to = xs_dict_get(object, "inReplyTo");
49 xs *wrk = NULL;
50
51- timeline_request(snac, &in_reply_to, &wrk);
52+ timeline_request(snac, &in_reply_to, &wrk, 0);
53
54 if (timeline_add(snac, id, object)) {
55 snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id));
56@@ -1521,7 +1522,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
57 if (xs_type(object) == XSTYPE_DICT)
58 object = xs_dict_get(object, "id");
59
60- timeline_request(snac, &object, &wrk);
61+ timeline_request(snac, &object, &wrk, 0);
62
63 /* Note: implementations like lemmy send announces about objects
64 that are not of the 'Note' type; these objects are not stored,