diff options
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/activitypub.c b/activitypub.c index 0535269..ed9acf9 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -645,12 +645,13 @@ xs_list *recipient_list(snac *snac, const xs_dict *msg, int expand_public) | |||
| 645 | 645 | ||
| 646 | while (xs_list_iter(&l, &v)) { | 646 | while (xs_list_iter(&l, &v)) { |
| 647 | if (expand_public) { | 647 | if (expand_public) { |
| 648 | xs *followers_url = xs_fmt("%s/followers", snac->actor); | ||
| 648 | if (strcmp(v, public_address) == 0 || | 649 | if (strcmp(v, public_address) == 0 || |
| 649 | /* check if it's a followers collection URL */ | 650 | /* check if it's a followers collection URL */ |
| 650 | (xs_type(v) == XSTYPE_STRING && | 651 | (xs_type(v) == XSTYPE_STRING && |
| 651 | strcmp(v, xs_fmt("%s/followers", snac->actor)) == 0) || | 652 | strcmp(v, followers_url) == 0) || |
| 652 | (xs_type(v) == XSTYPE_LIST && | 653 | (xs_type(v) == XSTYPE_LIST && |
| 653 | xs_list_in(v, xs_fmt("%s/followers", snac->actor)) != -1)) { | 654 | xs_list_in(v, followers_url) != -1)) { |
| 654 | /* iterate the followers and add them */ | 655 | /* iterate the followers and add them */ |
| 655 | xs *fwers = follower_list(snac); | 656 | xs *fwers = follower_list(snac); |
| 656 | const char *actor; | 657 | const char *actor; |
| @@ -1624,6 +1625,7 @@ xs_dict *msg_emoji_init(snac *snac, const char *mid, const char *eid_o) | |||
| 1624 | else if (*eid == '%') { | 1625 | else if (*eid == '%') { |
| 1625 | content = xs_url_dec_emoji(xs_dup(eid)); | 1626 | content = xs_url_dec_emoji(xs_dup(eid)); |
| 1626 | if (content == NULL) { | 1627 | if (content == NULL) { |
| 1628 | xs_free(n_msg); | ||
| 1627 | return NULL; | 1629 | return NULL; |
| 1628 | } | 1630 | } |
| 1629 | } | 1631 | } |
| @@ -1631,8 +1633,10 @@ xs_dict *msg_emoji_init(snac *snac, const char *mid, const char *eid_o) | |||
| 1631 | content = xs_fmt(":%s:", eid); | 1633 | content = xs_fmt(":%s:", eid); |
| 1632 | const char *emo = xs_dict_get(emjs, content); | 1634 | const char *emo = xs_dict_get(emjs, content); |
| 1633 | 1635 | ||
| 1634 | if (emo == NULL) | 1636 | if (emo == NULL) { |
| 1637 | xs_free(n_msg); | ||
| 1635 | return NULL; | 1638 | return NULL; |
| 1639 | } | ||
| 1636 | 1640 | ||
| 1637 | if (xs_match(emo, "https://*|http://*")) { /* emoji is an URL to an image */ | 1641 | if (xs_match(emo, "https://*|http://*")) { /* emoji is an URL to an image */ |
| 1638 | icon = xs_dict_set(icon, "type", "Image"); | 1642 | icon = xs_dict_set(icon, "type", "Image"); |
| @@ -1667,9 +1671,10 @@ xs_dict *msg_emoji_init(snac *snac, const char *mid, const char *eid_o) | |||
| 1667 | 1671 | ||
| 1668 | accounts = xs_list_append(accounts, snac->actor); | 1672 | accounts = xs_list_append(accounts, snac->actor); |
| 1669 | 1673 | ||
| 1674 | xs *to_duplicate = xs_dup(xs_list_get(xs_dict_get(n_msg, "to"), 1)); | ||
| 1670 | n_msg = xs_dict_set(n_msg, "content", content); | 1675 | n_msg = xs_dict_set(n_msg, "content", content); |
| 1671 | n_msg = xs_dict_set(n_msg, "accounts", accounts); | 1676 | n_msg = xs_dict_set(n_msg, "accounts", accounts); |
| 1672 | n_msg = xs_dict_set(n_msg, "attributedTo", xs_list_get(xs_dict_get(n_msg, "to"), 1)); | 1677 | n_msg = xs_dict_set(n_msg, "attributedTo", to_duplicate); |
| 1673 | n_msg = xs_dict_set(n_msg, "accountId", snac->uid); | 1678 | n_msg = xs_dict_set(n_msg, "accountId", snac->uid); |
| 1674 | n_msg = xs_dict_set(n_msg, "tag", tag); | 1679 | n_msg = xs_dict_set(n_msg, "tag", tag); |
| 1675 | 1680 | ||
| @@ -1679,6 +1684,7 @@ xs_dict *msg_emoji_init(snac *snac, const char *mid, const char *eid_o) | |||
| 1679 | return n_msg; | 1684 | return n_msg; |
| 1680 | } | 1685 | } |
| 1681 | 1686 | ||
| 1687 | xs_free(n_msg); | ||
| 1682 | return NULL; | 1688 | return NULL; |
| 1683 | } | 1689 | } |
| 1684 | 1690 | ||
| @@ -1710,13 +1716,14 @@ xs_dict *msg_emoji_unreact(snac *user, const char *mid, const char *eid) | |||
| 1710 | if (strlen(eid) == 12 && *eid == '%') { | 1716 | if (strlen(eid) == 12 && *eid == '%') { |
| 1711 | eid = xs_url_dec(eid); | 1717 | eid = xs_url_dec(eid); |
| 1712 | if (eid == NULL) { | 1718 | if (eid == NULL) { |
| 1719 | xs_free(msg); | ||
| 1713 | return NULL; | 1720 | return NULL; |
| 1714 | } | 1721 | } |
| 1715 | } | 1722 | } |
| 1716 | 1723 | ||
| 1717 | /* lets get all emotes for this msg, and compare it to our content */ | 1724 | /* lets get all emotes for this msg, and compare it to our content */ |
| 1718 | while (xs_list_next(emotes, &v, &c)) { | 1725 | while (xs_list_next(emotes, &v, &c)) { |
| 1719 | xs_dict *e = NULL; | 1726 | xs *e = NULL; |
| 1720 | if (valid_status(object_get_by_md5(v, &e))) { | 1727 | if (valid_status(object_get_by_md5(v, &e))) { |
| 1721 | const char *content = xs_dict_get(e, "content"); | 1728 | const char *content = xs_dict_get(e, "content"); |
| 1722 | const char *id = xs_dict_get(e, "id"); | 1729 | const char *id = xs_dict_get(e, "id"); |
| @@ -1730,6 +1737,7 @@ xs_dict *msg_emoji_unreact(snac *user, const char *mid, const char *eid) | |||
| 1730 | } | 1737 | } |
| 1731 | } | 1738 | } |
| 1732 | 1739 | ||
| 1740 | xs_free(msg); | ||
| 1733 | return NULL; | 1741 | return NULL; |
| 1734 | } | 1742 | } |
| 1735 | 1743 | ||