summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/activitypub.c b/activitypub.c
index f154515..f12aa47 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -631,7 +631,8 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char
631void notify(snac *snac, char *type, char *utype, char *actor, char *msg) 631void notify(snac *snac, char *type, char *utype, char *actor, char *msg)
632/* notifies the user of relevant events */ 632/* notifies the user of relevant events */
633{ 633{
634 char *email = xs_dict_get(snac->config, "email"); 634 char *email = xs_dict_get(snac->config, "email");
635 char *object = NULL;
635 636
636 /* no email address? done */ 637 /* no email address? done */
637 if (xs_is_null(email) || *email == '\0') 638 if (xs_is_null(email) || *email == '\0')
@@ -648,6 +649,21 @@ void notify(snac *snac, char *type, char *utype, char *actor, char *msg)
648 if (strcmp(type, "Undo") == 0 && strcmp(utype, "Follow") != 0) 649 if (strcmp(type, "Undo") == 0 && strcmp(utype, "Follow") != 0)
649 return; 650 return;
650 651
652 if (strcmp(type, "Like") == 0 || strcmp(type, "Announce") == 0) {
653 object = xs_str_get(msg, "object");
654
655 if (xs_is_null(object))
656 return;
657 else {
658 if (xs_type(object) == XSTYPE_DICT)
659 object = xs_dict_get(object, "id");
660
661 /* if it's not an admiration about something by us, done */
662 if (xs_is_null(object) || !xs_startswith(object, snac->actor))
663 return;
664 }
665 }
666
651 snac_debug(snac, 1, xs_fmt("notify(%s, %s, %s)", type, utype, actor)); 667 snac_debug(snac, 1, xs_fmt("notify(%s, %s, %s)", type, utype, actor));
652 668
653 /* prepare message */ 669 /* prepare message */
@@ -678,19 +694,9 @@ void notify(snac *snac, char *type, char *utype, char *actor, char *msg)
678 body = xs_str_cat(body, s1); 694 body = xs_str_cat(body, s1);
679 } 695 }
680 696
681 if (strcmp(type, "Like") == 0 || strcmp(type, "Announce") == 0) { 697 if (object != NULL) {
682 /* there is a related object: add it */ 698 xs *s1 = xs_fmt("Object: %s\n", object);
683 char *object = xs_dict_get(msg, "object"); 699 body = xs_str_cat(body, s1);
684
685 if (!xs_is_null(object)) {
686 if (xs_type(object) == XSTYPE_DICT)
687 object = xs_dict_get(object, "id");
688
689 if (!xs_is_null(object)) {
690 xs *s1 = xs_fmt("Object: %s\n", object);
691 body = xs_str_cat(body, s1);
692 }
693 }
694 } 700 }
695 701
696 /* now write */ 702 /* now write */