diff options
| author | 2022-09-25 18:28:15 +0200 | |
|---|---|---|
| committer | 2022-09-25 18:28:15 +0200 | |
| commit | 6169932733a2fdc7d00a29669960770c4fbaf5d3 (patch) | |
| tree | 17ffceb40a8652c448160d7d091cfb5b7ad2f357 /activitypub.c | |
| parent | New function timeline_admire(). (diff) | |
| download | snac2-6169932733a2fdc7d00a29669960770c4fbaf5d3.tar.gz snac2-6169932733a2fdc7d00a29669960770c4fbaf5d3.tar.xz snac2-6169932733a2fdc7d00a29669960770c4fbaf5d3.zip | |
New function timeline_request().
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/activitypub.c b/activitypub.c index 07cf5d7..7c93ca5 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -75,6 +75,33 @@ int actor_request(snac *snac, char *actor, d_char **data) | |||
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | 77 | ||
| 78 | void timeline_request(snac *snac, char *id) | ||
| 79 | /* ensures that an entry and its ancestors are in the timeline */ | ||
| 80 | { | ||
| 81 | if (!xs_is_null(id)) { | ||
| 82 | /* is the admired object already there? */ | ||
| 83 | if (!timeline_here(snac, id)) { | ||
| 84 | int status; | ||
| 85 | xs *object = NULL; | ||
| 86 | |||
| 87 | /* no; download it */ | ||
| 88 | status = activitypub_request(snac, id, &object); | ||
| 89 | |||
| 90 | if (valid_status(status)) { | ||
| 91 | /* does it have an ancestor? */ | ||
| 92 | char *in_reply_to = xs_dict_get(object, "inReplyTo"); | ||
| 93 | |||
| 94 | /* recurse! */ | ||
| 95 | timeline_request(snac, in_reply_to); | ||
| 96 | |||
| 97 | /* finally store */ | ||
| 98 | timeline_add(snac, id, object, in_reply_to); | ||
| 99 | } | ||
| 100 | } | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | |||
| 78 | int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_size) | 105 | int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_size) |
| 79 | /* sends a message to an Inbox */ | 106 | /* sends a message to an Inbox */ |
| 80 | { | 107 | { |
| @@ -204,10 +231,7 @@ void process_message(snac *snac, char *msg, char *req) | |||
| 204 | char *id = xs_dict_get(object, "id"); | 231 | char *id = xs_dict_get(object, "id"); |
| 205 | char *in_reply_to = xs_dict_get(object, "inReplyTo"); | 232 | char *in_reply_to = xs_dict_get(object, "inReplyTo"); |
| 206 | 233 | ||
| 207 | if (xs_is_null(in_reply_to)) { | 234 | timeline_request(snac, in_reply_to); |
| 208 | /* recursively download ancestors */ | ||
| 209 | /* ... */ | ||
| 210 | } | ||
| 211 | 235 | ||
| 212 | snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id)); | 236 | snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id)); |
| 213 | timeline_add(snac, id, msg, in_reply_to); | 237 | timeline_add(snac, id, msg, in_reply_to); |
| @@ -229,17 +253,24 @@ void process_message(snac *snac, char *msg, char *req) | |||
| 229 | snac_debug(snac, 2, xs_fmt("xs_type for 'Like' object not string")); | 253 | snac_debug(snac, 2, xs_fmt("xs_type for 'Like' object not string")); |
| 230 | } | 254 | } |
| 231 | else | 255 | else |
| 232 | /* | 256 | if (strcmp(type, "Announce") == 0) { |
| 233 | || strcmp(type, "Announce") == 0) { | 257 | if (xs_type(object) == XSTYPE_STRING) { |
| 258 | timeline_request(snac, object); | ||
| 259 | |||
| 260 | timeline_admire(snac, object, actor, 0); | ||
| 261 | } | ||
| 262 | else | ||
| 263 | snac_debug(snac, 2, xs_fmt("xs_type for 'Announce' object not string")); | ||
| 234 | } | 264 | } |
| 265 | /* | ||
| 235 | else | 266 | else |
| 236 | if (strcmp(type, "Update") == 0) { | 267 | if (strcmp(type, "Update") == 0) { |
| 237 | } | 268 | } |
| 238 | else | 269 | else |
| 239 | if (strcmp(type, "Delete") == 0) { | 270 | if (strcmp(type, "Delete") == 0) { |
| 240 | } | 271 | } |
| 241 | else | ||
| 242 | */ | 272 | */ |
| 273 | else | ||
| 243 | snac_debug(snac, 1, xs_fmt("process_message type '%s' ignored", type)); | 274 | snac_debug(snac, 1, xs_fmt("process_message type '%s' ignored", type)); |
| 244 | } | 275 | } |
| 245 | 276 | ||