summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authorGravatar default2023-06-29 08:26:44 +0200
committerGravatar default2023-06-29 08:26:44 +0200
commita114d5094d253ed08ac59701396983c45b01a5d5 (patch)
tree611e73e0b8c95cd71fb7060631de391c4c87ff30 /activitypub.c
parentAdded command-line interface for [un]blocking full instances. (diff)
downloadsnac2-a114d5094d253ed08ac59701396983c45b01a5d5.tar.gz
snac2-a114d5094d253ed08ac59701396983c45b01a5d5.tar.xz
snac2-a114d5094d253ed08ac59701396983c45b01a5d5.zip
Call is_instance_blocked() from activitypub_post_handler().
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/activitypub.c b/activitypub.c
index 028e04e..ce72f3f 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1994,13 +1994,22 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path,
1994 1994
1995 /* decode the message */ 1995 /* decode the message */
1996 xs *msg = xs_json_loads(payload); 1996 xs *msg = xs_json_loads(payload);
1997 const char *id;
1997 1998
1998 if (msg == NULL) { 1999 if (msg == NULL || xs_is_null(id = xs_dict_get(msg, "id"))) {
1999 srv_log(xs_fmt("activitypub_post_handler JSON error %s", q_path)); 2000 srv_log(xs_fmt("activitypub_post_handler JSON error %s", q_path));
2000 2001
2001 *body = xs_str_new("JSON error"); 2002 *body = xs_str_new("JSON error");
2002 *ctype = "text/plain"; 2003 *ctype = "text/plain";
2003 status = 400; 2004 return 400;
2005 }
2006
2007 if (is_instance_blocked(id)) {
2008 srv_debug(1, xs_fmt("full instance block for %s", id));
2009
2010 *body = xs_str_new("blocked");
2011 *ctype = "text/plain";
2012 return 403;
2004 } 2013 }
2005 2014
2006 /* get the user and path */ 2015 /* get the user and path */