summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authorGravatar default2023-07-13 20:19:50 +0200
committerGravatar default2023-07-13 20:19:50 +0200
commita05aa969d0cd2efbd08bbeda69544ceb8f26a388 (patch)
tree7e3df96a9075f4316d4372b2807cf8ba87dd3a37 /activitypub.c
parentAlways log send status in post_message(). (diff)
downloadsnac2-a05aa969d0cd2efbd08bbeda69544ceb8f26a388.tar.gz
snac2-a05aa969d0cd2efbd08bbeda69544ceb8f26a388.tar.xz
snac2-a05aa969d0cd2efbd08bbeda69544ceb8f26a388.zip
Added a maximum level of recursion to timeline_request().
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/activitypub.c b/activitypub.c
index 2566ba4..4843067 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -146,7 +146,7 @@ int actor_request(snac *snac, const char *actor, xs_dict **data)
146} 146}
147 147
148 148
149int timeline_request(snac *snac, char **id, xs_str **wrk) 149int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
150/* ensures that an entry and its ancestors are in the timeline */ 150/* ensures that an entry and its ancestors are in the timeline */
151{ 151{
152 int status = 0; 152 int status = 0;
@@ -187,7 +187,8 @@ int timeline_request(snac *snac, char **id, xs_str **wrk)
187 timeline_add(snac, *id, object); 187 timeline_add(snac, *id, object);
188 188
189 /* recurse! */ 189 /* recurse! */
190 timeline_request(snac, &in_reply_to, NULL); 190 if (level < 32)
191 timeline_request(snac, &in_reply_to, NULL, level + 1);
191 } 192 }
192 } 193 }
193 } 194 }
@@ -255,7 +256,7 @@ void timeline_request_replies(snac *user, const char *id)
255 } 256 }
256 else { 257 else {
257 snac_debug(user, 0, xs_fmt("request reply %s", v)); 258 snac_debug(user, 0, xs_fmt("request reply %s", v));
258 timeline_request(user, &v, NULL); 259 timeline_request(user, &v, NULL, 0);
259 } 260 }
260 } 261 }
261 } 262 }
@@ -830,7 +831,7 @@ xs_dict *msg_admiration(snac *snac, char *object, char *type)
830 xs *wrk = NULL; 831 xs *wrk = NULL;
831 832
832 /* call the object */ 833 /* call the object */
833 timeline_request(snac, &object, &wrk); 834 timeline_request(snac, &object, &wrk, 0);
834 835
835 if (valid_status(object_get(object, &a_msg))) { 836 if (valid_status(object_get(object, &a_msg))) {
836 xs *rcpts = xs_list_new(); 837 xs *rcpts = xs_list_new();
@@ -1039,7 +1040,7 @@ xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts,
1039 xs *wrk = NULL; 1040 xs *wrk = NULL;
1040 1041
1041 /* demand this thing */ 1042 /* demand this thing */
1042 timeline_request(snac, &in_reply_to, &wrk); 1043 timeline_request(snac, &in_reply_to, &wrk, 0);
1043 1044
1044 if (valid_status(object_get(in_reply_to, &p_msg))) { 1045 if (valid_status(object_get(in_reply_to, &p_msg))) {
1045 /* add this author as recipient */ 1046 /* add this author as recipient */
@@ -1468,7 +1469,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
1468 char *in_reply_to = xs_dict_get(object, "inReplyTo"); 1469 char *in_reply_to = xs_dict_get(object, "inReplyTo");
1469 xs *wrk = NULL; 1470 xs *wrk = NULL;
1470 1471
1471 timeline_request(snac, &in_reply_to, &wrk); 1472 timeline_request(snac, &in_reply_to, &wrk, 0);
1472 1473
1473 if (timeline_add(snac, id, object)) { 1474 if (timeline_add(snac, id, object)) {
1474 snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id)); 1475 snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id));
@@ -1521,7 +1522,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
1521 if (xs_type(object) == XSTYPE_DICT) 1522 if (xs_type(object) == XSTYPE_DICT)
1522 object = xs_dict_get(object, "id"); 1523 object = xs_dict_get(object, "id");
1523 1524
1524 timeline_request(snac, &object, &wrk); 1525 timeline_request(snac, &object, &wrk, 0);
1525 1526
1526 /* Note: implementations like lemmy send announces about objects 1527 /* Note: implementations like lemmy send announces about objects
1527 that are not of the 'Note' type; these objects are not stored, 1528 that are not of the 'Note' type; these objects are not stored,