summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c100
1 files changed, 50 insertions, 50 deletions
diff --git a/activitypub.c b/activitypub.c
index 1dedd17..5e1dd55 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -390,71 +390,71 @@ int timeline_request(snac *snac, const char **id, xs_str **wrk, int level)
390 } 390 }
391 391
392 /* is the object already there? */ 392 /* is the object already there? */
393 if (!valid_status(object_get(*id, &msg))) { 393 if (!valid_status((status = object_get(*id, &msg)))) {
394 /* no; download it */ 394 /* no; download it */
395 status = activitypub_request(snac, *id, &msg); 395 status = activitypub_request(snac, *id, &msg);
396 }
396 397
397 if (valid_status(status)) { 398 if (valid_status(status)) {
398 const xs_dict *object = msg; 399 const xs_dict *object = msg;
399 const char *type = xs_dict_get(object, "type"); 400 const char *type = xs_dict_get(object, "type");
400 401
401 /* get the id again from the object, as it may be different */ 402 /* get the id again from the object, as it may be different */
402 const char *nid = xs_dict_get(object, "id"); 403 const char *nid = xs_dict_get(object, "id");
403 404
404 if (xs_type(nid) != XSTYPE_STRING) 405 if (xs_type(nid) != XSTYPE_STRING)
405 return 0; 406 return 0;
406 407
407 if (wrk && strcmp(nid, *id) != 0) { 408 if (wrk && strcmp(nid, *id) != 0) {
408 snac_debug(snac, 1, 409 snac_debug(snac, 1,
409 xs_fmt("timeline_request canonical id for %s is %s", *id, nid)); 410 xs_fmt("timeline_request canonical id for %s is %s", *id, nid));
410 411
411 *wrk = xs_dup(nid); 412 *wrk = xs_dup(nid);
412 *id = *wrk; 413 *id = *wrk;
413 } 414 }
414 415
415 if (xs_is_null(type)) 416 if (xs_is_null(type))
416 type = "(null)"; 417 type = "(null)";
417 418
418 srv_debug(2, xs_fmt("timeline_request type %s '%s'", nid, type)); 419 srv_debug(2, xs_fmt("timeline_request type %s '%s'", nid, type));
419 420
420 if (strcmp(type, "Create") == 0) { 421 if (strcmp(type, "Create") == 0) {
421 /* some software like lemmy nest Announce + Create + Note */ 422 /* some software like lemmy nest Announce + Create + Note */
422 if (!xs_is_null(object = xs_dict_get(object, "object"))) { 423 if (!xs_is_null(object = xs_dict_get(object, "object"))) {
423 type = xs_dict_get(object, "type"); 424 type = xs_dict_get(object, "type");
424 nid = xs_dict_get(object, "id"); 425 nid = xs_dict_get(object, "id");
425 }
426 else
427 type = "(null)";
428 } 426 }
427 else
428 type = "(null)";
429 }
429 430
430 if (xs_match(type, POSTLIKE_OBJECT_TYPE)) { 431 if (xs_match(type, POSTLIKE_OBJECT_TYPE)) {
431 if (content_match("filter_reject.txt", object)) 432 if (content_match("filter_reject.txt", object))
432 snac_log(snac, xs_fmt("timeline_request rejected by content %s", nid)); 433 snac_log(snac, xs_fmt("timeline_request rejected by content %s", nid));
433 else 434 else
434 if (blocked_hashtag_check(snac, object)) 435 if (blocked_hashtag_check(snac, object))
435 snac_log(snac, xs_fmt("timeline_request rejected by hashtag %s", nid)); 436 snac_log(snac, xs_fmt("timeline_request rejected by hashtag %s", nid));
436 else { 437 else {
437 const char *actor = get_atto(object); 438 const char *actor = get_atto(object);
438 439
439 if (!xs_is_null(actor)) { 440 if (!xs_is_null(actor)) {
440 /* request (and drop) the actor for this entry */ 441 /* request (and drop) the actor for this entry */
441 if (!valid_status(actor_request(snac, actor, NULL))) { 442 if (!valid_status(actor_request(snac, actor, NULL))) {
442 /* failed? retry later */ 443 /* failed? retry later */
443 enqueue_actor_refresh(snac, actor, 60); 444 enqueue_actor_refresh(snac, actor, 60);
444 } 445 }
445 446
446 /* does it have an ancestor? */ 447 /* does it have an ancestor? */
447 const char *in_reply_to = get_in_reply_to(object); 448 const char *in_reply_to = get_in_reply_to(object);
448 449
449 /* store */ 450 /* store */
450 timeline_add(snac, nid, object); 451 timeline_add(snac, nid, object);
451 452
452 /* redistribute to lists for this user */ 453 /* redistribute to lists for this user */
453 list_distribute(snac, actor, object); 454 list_distribute(snac, actor, object);
454 455
455 /* recurse! */ 456 /* recurse! */
456 timeline_request(snac, &in_reply_to, NULL, level + 1); 457 timeline_request(snac, &in_reply_to, NULL, level + 1);
457 }
458 } 458 }
459 } 459 }
460 } 460 }
@@ -2360,7 +2360,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
2360 xs *this_relay = xs_fmt("%s/relay", srv_baseurl); 2360 xs *this_relay = xs_fmt("%s/relay", srv_baseurl);
2361 2361
2362 if (strcmp(actor, this_relay) != 0) { 2362 if (strcmp(actor, this_relay) != 0) {
2363 if (timeline_admire(snac, object, actor, 0) == HTTP_STATUS_CREATED) 2363 if (valid_status(timeline_admire(snac, object, actor, 0)))
2364 snac_log(snac, xs_fmt("new 'Announce' %s %s", actor, object)); 2364 snac_log(snac, xs_fmt("new 'Announce' %s %s", actor, object));
2365 else 2365 else
2366 snac_log(snac, xs_fmt("repeated 'Announce' from %s to %s", 2366 snac_log(snac, xs_fmt("repeated 'Announce' from %s to %s",