summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/activitypub.c b/activitypub.c
index 0368ac8..90230d8 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -779,7 +779,7 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg)
779 object_get(object, &obj); 779 object_get(object, &obj);
780 780
781 /* if it's about one of our posts, accept it */ 781 /* if it's about one of our posts, accept it */
782 if (xs_startswith(object, snac->actor)) 782 if (is_msg_mine(snac, object))
783 return 2; 783 return 2;
784 784
785 /* blocked by hashtag? */ 785 /* blocked by hashtag? */
@@ -1242,7 +1242,7 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor,
1242 1242
1243 if (xs_match(type, "Like|Announce|EmojiReact")) { 1243 if (xs_match(type, "Like|Announce|EmojiReact")) {
1244 /* if it's not an admiration about something by us, done */ 1244 /* if it's not an admiration about something by us, done */
1245 if (xs_is_null(objid) || !xs_startswith(objid, snac->actor)) 1245 if (xs_is_null(objid) || !is_msg_mine(snac, objid))
1246 return; 1246 return;
1247 1247
1248 /* if it's an announce by our own relay, done */ 1248 /* if it's an announce by our own relay, done */
@@ -1267,7 +1267,7 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor,
1267 return; 1267 return;
1268 1268
1269 /* if it's not ours and we didn't vote, discard */ 1269 /* if it's not ours and we didn't vote, discard */
1270 if (!xs_startswith(poll_id, snac->actor) && !was_question_voted(snac, poll_id)) 1270 if (!is_msg_mine(snac, poll_id) && !was_question_voted(snac, poll_id))
1271 return; 1271 return;
1272 } 1272 }
1273 1273
@@ -2686,6 +2686,20 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
2686 2686
2687 timeline_request(snac, &in_reply_to, &wrk, 0); 2687 timeline_request(snac, &in_reply_to, &wrk, 0);
2688 2688
2689 const char *quoted_id = xs_or(xs_dict_get(object, "quoteUri"), xs_dict_get(object, "quoteUrl"));
2690
2691 if (xs_is_string(quoted_id) && xs_match(quoted_id, "https://*|http://*")) { /** **/
2692 xs *quoted_post = NULL;
2693 int status;
2694
2695 if (valid_status(status = activitypub_request(snac, quoted_id, &quoted_post))) {
2696 /* got quoted post */
2697 object_add(quoted_id, quoted_post);
2698 }
2699
2700 snac_debug(snac, 1, xs_fmt("retrieving quoted post %s %d", quoted_id, status));
2701 }
2702
2689 if (timeline_add(snac, id, object)) { 2703 if (timeline_add(snac, id, object)) {
2690 snac_log(snac, xs_fmt("new '%s' %s %s", utype, actor, id)); 2704 snac_log(snac, xs_fmt("new '%s' %s %s", utype, actor, id));
2691 do_notify = 1; 2705 do_notify = 1;
@@ -2778,10 +2792,10 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
2778 if (xs_is_null(object)) 2792 if (xs_is_null(object))
2779 snac_log(snac, xs_fmt("malformed message: no 'id' field")); 2793 snac_log(snac, xs_fmt("malformed message: no 'id' field"));
2780 else 2794 else
2781 if (is_muted(snac, actor) && !xs_startswith(object, snac->actor)) 2795 if (is_muted(snac, actor) && !is_msg_mine(snac, object))
2782 snac_log(snac, xs_fmt("dropped 'Announce' from muted actor %s", actor)); 2796 snac_log(snac, xs_fmt("dropped 'Announce' from muted actor %s", actor));
2783 else 2797 else
2784 if (is_limited(snac, actor) && !xs_startswith(object, snac->actor)) 2798 if (is_limited(snac, actor) && !is_msg_mine(snac, object))
2785 snac_log(snac, xs_fmt("dropped 'Announce' from limited actor %s", actor)); 2799 snac_log(snac, xs_fmt("dropped 'Announce' from limited actor %s", actor));
2786 else { 2800 else {
2787 xs *a_msg = NULL; 2801 xs *a_msg = NULL;
@@ -2792,6 +2806,9 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
2792 if (valid_status(object_get(object, &a_msg))) { 2806 if (valid_status(object_get(object, &a_msg))) {
2793 const char *who = get_atto(a_msg); 2807 const char *who = get_atto(a_msg);
2794 2808
2809 /* got the admired object: instance is [back] online */
2810 instance_failure(object, 2);
2811
2795 if (who && !is_muted(snac, who)) { 2812 if (who && !is_muted(snac, who)) {
2796 /* bring the actor */ 2813 /* bring the actor */
2797 xs *who_o = NULL; 2814 xs *who_o = NULL;
@@ -2886,7 +2903,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
2886 snac_log(snac, xs_fmt("malformed message: no 'id' field")); 2903 snac_log(snac, xs_fmt("malformed message: no 'id' field"));
2887 else 2904 else
2888 if (object_here(object)) { 2905 if (object_here(object)) {
2889 if (xs_startswith(object, srv_baseurl) && !xs_startswith(object, actor)) 2906 if (xs_startswith(object, srv_baseurl) && !is_msg_mine(snac, object))
2890 snac_log(snac, xs_fmt("ignored incorrect 'Delete' %s %s", actor, object)); 2907 snac_log(snac, xs_fmt("ignored incorrect 'Delete' %s %s", actor, object));
2891 else { 2908 else {
2892 timeline_del(snac, object); 2909 timeline_del(snac, object);
@@ -3699,7 +3716,7 @@ int activitypub_get_handler(const xs_dict *req, const char *q_path,
3699 const char *type = xs_dict_get(i, "type"); 3716 const char *type = xs_dict_get(i, "type");
3700 const char *id = xs_dict_get(i, "id"); 3717 const char *id = xs_dict_get(i, "id");
3701 3718
3702 if (type && id && strcmp(type, "Note") == 0 && xs_startswith(id, snac.actor)) { 3719 if (type && id && strcmp(type, "Note") == 0 && is_msg_mine(&snac, id)) {
3703 if (is_msg_public(i)) { 3720 if (is_msg_public(i)) {
3704 xs *c_msg = msg_create(&snac, i); 3721 xs *c_msg = msg_create(&snac, i);
3705 list = xs_list_append(list, c_msg); 3722 list = xs_list_append(list, c_msg);