summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/activitypub.c b/activitypub.c
index d4685a1..792080d 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -846,8 +846,6 @@ xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts,
846void notify(snac *snac, xs_str *type, xs_str *utype, xs_str *actor, xs_dict *msg) 846void notify(snac *snac, xs_str *type, xs_str *utype, xs_str *actor, xs_dict *msg)
847/* notifies the user of relevant events */ 847/* notifies the user of relevant events */
848{ 848{
849 xs_val *object = NULL;
850
851 if (strcmp(type, "Create") == 0) { 849 if (strcmp(type, "Create") == 0) {
852 /* only notify of notes specifically for us */ 850 /* only notify of notes specifically for us */
853 xs *rcpts = recipient_list(snac, msg, 0); 851 xs *rcpts = recipient_list(snac, msg, 0);
@@ -859,21 +857,20 @@ void notify(snac *snac, xs_str *type, xs_str *utype, xs_str *actor, xs_dict *msg
859 if (strcmp(type, "Undo") == 0 && strcmp(utype, "Follow") != 0) 857 if (strcmp(type, "Undo") == 0 && strcmp(utype, "Follow") != 0)
860 return; 858 return;
861 859
862 if (strcmp(type, "Like") == 0 || strcmp(type, "Announce") == 0) { 860 /* get the object id */
863 object = xs_dict_get(msg, "object"); 861 const char *objid = xs_dict_get(msg, "object");
864 862
865 if (xs_is_null(object)) 863 if (xs_type(objid) == XSTYPE_DICT)
866 return; 864 objid = xs_dict_get(objid, "id");
867 else {
868 if (xs_type(object) == XSTYPE_DICT)
869 object = xs_dict_get(object, "id");
870 865
871 /* if it's not an admiration about something by us, done */ 866 if (strcmp(type, "Like") == 0 || strcmp(type, "Announce") == 0) {
872 if (xs_is_null(object) || !xs_startswith(object, snac->actor)) 867 /* if it's not an admiration about something by us, done */
873 return; 868 if (xs_is_null(objid) || !xs_startswith(objid, snac->actor))
874 } 869 return;
875 } 870 }
876 871
872 /* user will love to know about this! */
873
877 /* prepare message body */ 874 /* prepare message body */
878 xs *body = xs_fmt("User : @%s@%s\n", 875 xs *body = xs_fmt("User : @%s@%s\n",
879 xs_dict_get(snac->config, "uid"), 876 xs_dict_get(snac->config, "uid"),
@@ -894,8 +891,8 @@ void notify(snac *snac, xs_str *type, xs_str *utype, xs_str *actor, xs_dict *msg
894 body = xs_str_cat(body, s1); 891 body = xs_str_cat(body, s1);
895 } 892 }
896 893
897 if (object != NULL) { 894 if (objid != NULL) {
898 xs *s1 = xs_fmt("Object: %s\n", object); 895 xs *s1 = xs_fmt("Object: %s\n", objid);
899 body = xs_str_cat(body, s1); 896 body = xs_str_cat(body, s1);
900 } 897 }
901 898