summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/activitypub.c b/activitypub.c
index 92e7c6c..64155c0 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -78,7 +78,7 @@ int actor_request(snac *snac, char *actor, d_char **data)
78} 78}
79 79
80 80
81int timeline_request(snac *snac, char **id, char *referrer) 81int timeline_request(snac *snac, char **id, char *referrer, d_char **wrk)
82/* ensures that an entry and its ancestors are in the timeline */ 82/* ensures that an entry and its ancestors are in the timeline */
83{ 83{
84 int status = 0; 84 int status = 0;
@@ -97,12 +97,12 @@ int timeline_request(snac *snac, char **id, char *referrer)
97 /* get the id again from the object, as it may be different */ 97 /* get the id again from the object, as it may be different */
98 char *nid = xs_dict_get(object, "id"); 98 char *nid = xs_dict_get(object, "id");
99 99
100 if (strcmp(nid, *id) != 0) { 100 if (wrk && strcmp(nid, *id) != 0) {
101 snac_debug(snac, 1, 101 snac_debug(snac, 1,
102 xs_fmt("timeline_request canonical id for %s is %s", *id, nid)); 102 xs_fmt("timeline_request canonical id for %s is %s", *id, nid));
103 103
104 /* FIXME: nid points inside a dynamic block */ 104 *wrk = xs_dup(nid);
105 *id = nid; 105 *id = *wrk;
106 } 106 }
107 107
108 if (!xs_is_null(type) && strcmp(type, "Note") == 0) { 108 if (!xs_is_null(type) && strcmp(type, "Note") == 0) {
@@ -116,7 +116,7 @@ int timeline_request(snac *snac, char **id, char *referrer)
116 char *in_reply_to = xs_dict_get(object, "inReplyTo"); 116 char *in_reply_to = xs_dict_get(object, "inReplyTo");
117 117
118 /* recurse! */ 118 /* recurse! */
119 timeline_request(snac, &in_reply_to, referrer); 119 timeline_request(snac, &in_reply_to, referrer, NULL);
120 120
121 /* finally store */ 121 /* finally store */
122 timeline_add(snac, *id, object, in_reply_to, referrer); 122 timeline_add(snac, *id, object, in_reply_to, referrer);
@@ -419,9 +419,10 @@ d_char *msg_admiration(snac *snac, char *object, char *type)
419{ 419{
420 xs *a_msg = NULL; 420 xs *a_msg = NULL;
421 d_char *msg = NULL; 421 d_char *msg = NULL;
422 xs *wrk = NULL;
422 423
423 /* call the object */ 424 /* call the object */
424 timeline_request(snac, &object, snac->actor); 425 timeline_request(snac, &object, snac->actor, &wrk);
425 426
426 if (valid_status(object_get(object, &a_msg, NULL))) { 427 if (valid_status(object_get(object, &a_msg, NULL))) {
427 xs *rcpts = xs_list_new(); 428 xs *rcpts = xs_list_new();
@@ -612,9 +613,10 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char
612 613
613 if (in_reply_to != NULL && *in_reply_to) { 614 if (in_reply_to != NULL && *in_reply_to) {
614 xs *p_msg = NULL; 615 xs *p_msg = NULL;
616 xs *wrk = NULL;
615 617
616 /* demand this thing */ 618 /* demand this thing */
617 timeline_request(snac, &in_reply_to, NULL); 619 timeline_request(snac, &in_reply_to, NULL, &wrk);
618 620
619 if (valid_status(object_get(in_reply_to, &p_msg, NULL))) { 621 if (valid_status(object_get(in_reply_to, &p_msg, NULL))) {
620 /* add this author as recipient */ 622 /* add this author as recipient */
@@ -886,8 +888,9 @@ int process_message(snac *snac, char *msg, char *req)
886 else { 888 else {
887 char *id = xs_dict_get(object, "id"); 889 char *id = xs_dict_get(object, "id");
888 char *in_reply_to = xs_dict_get(object, "inReplyTo"); 890 char *in_reply_to = xs_dict_get(object, "inReplyTo");
891 xs *wrk = NULL;
889 892
890 timeline_request(snac, &in_reply_to, NULL); 893 timeline_request(snac, &in_reply_to, NULL, &wrk);
891 894
892 if (timeline_add(snac, id, object, in_reply_to, NULL)) { 895 if (timeline_add(snac, id, object, in_reply_to, NULL)) {
893 snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id)); 896 snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id));
@@ -923,11 +926,12 @@ int process_message(snac *snac, char *msg, char *req)
923 else 926 else
924 if (strcmp(type, "Announce") == 0) { 927 if (strcmp(type, "Announce") == 0) {
925 xs *a_msg = NULL; 928 xs *a_msg = NULL;
929 xs *wrk = NULL;
926 930
927 if (xs_type(object) == XSTYPE_DICT) 931 if (xs_type(object) == XSTYPE_DICT)
928 object = xs_dict_get(object, "id"); 932 object = xs_dict_get(object, "id");
929 933
930 timeline_request(snac, &object, actor); 934 timeline_request(snac, &object, actor, &wrk);
931 935
932 if (valid_status(object_get(object, &a_msg, NULL))) { 936 if (valid_status(object_get(object, &a_msg, NULL))) {
933 char *who = xs_dict_get(a_msg, "attributedTo"); 937 char *who = xs_dict_get(a_msg, "attributedTo");