summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c35
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)
154 } 154 }
155 } 155 }
156} 156}
157
158
159int activitypub_post_handler(d_char *req, char *q_path,
160 d_char *payload, int p_size,
161 char **body, int *b_size, char **ctype)
162/* processes an input message */
163{
164 int status = 200;
165 char *i_ctype = xs_dict_get(req, "content-type");
166 snac snac;
167
168 if (xs_str_in(i_ctype, "application/activity+json") == -1 &&
169 xs_str_in(i_ctype, "application/ld+json") == -1)
170 return 0;
171
172 xs *l = xs_split_n(q_path, "/", 2);
173 char *uid;
174
175 if (xs_list_len(l) != 3 || strcmp(xs_list_get(l, 2), "inbox") != 0) {
176 /* strange q_path */
177 srv_log(xs_fmt("activitypub_post_handler unsupported path %s", q_path));
178 return 404;
179 }
180
181 uid = xs_list_get(l, 1);
182 if (!user_open(&snac, uid)) {
183 /* invalid user */
184 srv_log(xs_fmt("activitypub_post_handler bad user %s", uid));
185 return 404;
186 }
187
188 user_free(&snac);
189
190 return status;
191}