diff options
author | default <nobody@localhost> | 2022-09-23 20:28:23 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2022-09-23 20:28:23 +0200 |
commit | 1d694a245a56bb4fd90fd917ad3648c2c5449746 (patch) | |
tree | cb96eb621ca84ebfdfba40cf859af477639f75d6 /activitypub.c | |
parent | bbf5471039a973fed918441150ef76ff0db7682a (diff) |
xs_httpd_request() also returns the payload.
Diffstat (limited to 'activitypub.c')
-rw-r--r-- | activitypub.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c index b654beb..d470e10 100644 --- a/activitypub.c +++ b/activitypub.c @@ -154,3 +154,38 @@ void process_queue(snac *snac) } } } + + +int activitypub_post_handler(d_char *req, char *q_path, + d_char *payload, int p_size, + char **body, int *b_size, char **ctype) +/* processes an input message */ +{ + int status = 200; + char *i_ctype = xs_dict_get(req, "content-type"); + snac snac; + + if (xs_str_in(i_ctype, "application/activity+json") == -1 && + xs_str_in(i_ctype, "application/ld+json") == -1) + return 0; + + xs *l = xs_split_n(q_path, "/", 2); + char *uid; + + if (xs_list_len(l) != 3 || strcmp(xs_list_get(l, 2), "inbox") != 0) { + /* strange q_path */ + srv_log(xs_fmt("activitypub_post_handler unsupported path %s", q_path)); + return 404; + } + + uid = xs_list_get(l, 1); + if (!user_open(&snac, uid)) { + /* invalid user */ + srv_log(xs_fmt("activitypub_post_handler bad user %s", uid)); + return 404; + } + + user_free(&snac); + + return status; +} |