summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2023-12-17 17:07:26 +0100
committerGravatar default2023-12-17 17:07:26 +0100
commit04745f5f7d240fe36a7d0a864132ad9fcc4ea4b0 (patch)
tree8b2a96104b1361874a6fd7f3e290db153fb66a67
parentEven more is_msg_for_me() tweaks. (diff)
downloadsnac2-04745f5f7d240fe36a7d0a864132ad9fcc4ea4b0.tar.gz
snac2-04745f5f7d240fe36a7d0a864132ad9fcc4ea4b0.tar.xz
snac2-04745f5f7d240fe36a7d0a864132ad9fcc4ea4b0.zip
Blah blah blah is_msg_for_me() blah blah blah
-rw-r--r--activitypub.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/activitypub.c b/activitypub.c
index 77a496f..2f7c424 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -478,8 +478,10 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg)
478 return 1; 478 return 1;
479 } 479 }
480 480
481 /* if we follow the actor of this post, allow */ 481 int pub_msg = is_msg_public(c_msg);
482 if (following_check(snac, actor)) 482
483 /* if this message is public and we follow the actor of this post, allow */
484 if (pub_msg && following_check(snac, actor))
483 return 1; 485 return 1;
484 486
485 xs_dict *msg = xs_dict_get(c_msg, "object"); 487 xs_dict *msg = xs_dict_get(c_msg, "object");
@@ -493,14 +495,14 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg)
493 return 2; 495 return 2;
494 496
495 /* for someone we follow? (probably cc'ed) accept */ 497 /* for someone we follow? (probably cc'ed) accept */
496 if (following_check(snac, v)) 498 if (pub_msg && following_check(snac, v))
497 return 5; 499 return 5;
498 } 500 }
499 501
500 /* accept if it's by someone we follow */ 502 /* accept if it's by someone we follow */
501 char *atto = xs_dict_get(msg, "attributedTo"); 503 char *atto = xs_dict_get(msg, "attributedTo");
502 504
503 if (!xs_is_null(atto) && following_check(snac, atto)) 505 if (pub_msg && !xs_is_null(atto) && following_check(snac, atto))
504 return 3; 506 return 3;
505 507
506 /* is this message a reply to another? */ 508 /* is this message a reply to another? */
@@ -513,11 +515,13 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg)
513 atto = xs_dict_get(r_msg, "attributedTo"); 515 atto = xs_dict_get(r_msg, "attributedTo");
514 516
515 /* accept if the replied message is from someone we follow */ 517 /* accept if the replied message is from someone we follow */
516 if (!xs_is_null(atto) && following_check(snac, atto)) 518 if (pub_msg && !xs_is_null(atto) && following_check(snac, atto))
517 return 4; 519 return 4;
518 } 520 }
519 } 521 }
520 522
523 snac_debug(snac, 0, xs_fmt("is_msg_for_me() final"));
524
521 return 0; 525 return 0;
522} 526}
523 527