diff options
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; +} |