summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/activitypub.c b/activitypub.c
index f6660db..75b84ec 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1180,7 +1180,22 @@ void process_queue_item(xs_dict *q_item)
1180 /* deliver */ 1180 /* deliver */
1181 status = send_to_inbox_raw(keyid, seckey, inbox, msg, &payload, &p_size, retries == 0 ? 3 : 8); 1181 status = send_to_inbox_raw(keyid, seckey, inbox, msg, &payload, &p_size, retries == 0 ? 3 : 8);
1182 1182
1183 srv_log(xs_fmt("output message: sent to inbox %s %d", inbox, status)); 1183 if (payload && !valid_status(status)) {
1184 /* in case of error, print a part of the payload,
1185 as it may be informative */
1186 if (p_size > 24) {
1187 /* trim the message */
1188 payload[24] = '\0';
1189 payload = xs_str_cat(payload, "...");
1190 }
1191
1192 payload = xs_str_wrap_i(" (", payload, ")");
1193 }
1194
1195 if (payload == NULL)
1196 payload = xs_str_new(NULL);
1197
1198 srv_log(xs_fmt("output message: sent to inbox %s %d%s", inbox, status, payload));
1184 1199
1185 if (!valid_status(status)) { 1200 if (!valid_status(status)) {
1186 retries++; 1201 retries++;
@@ -1377,8 +1392,11 @@ int activitypub_post_handler(d_char *req, char *q_path,
1377 snac snac; 1392 snac snac;
1378 char *v; 1393 char *v;
1379 1394
1380 if (i_ctype == NULL) 1395 if (i_ctype == NULL) {
1396 *body = xs_str_new("no content-type");
1397 *ctype = "text/plain";
1381 return 400; 1398 return 400;
1399 }
1382 1400
1383 if (xs_str_in(i_ctype, "application/activity+json") == -1 && 1401 if (xs_str_in(i_ctype, "application/activity+json") == -1 &&
1384 xs_str_in(i_ctype, "application/ld+json") == -1) 1402 xs_str_in(i_ctype, "application/ld+json") == -1)
@@ -1389,6 +1407,9 @@ int activitypub_post_handler(d_char *req, char *q_path,
1389 1407
1390 if (msg == NULL) { 1408 if (msg == NULL) {
1391 srv_log(xs_fmt("activitypub_post_handler JSON error %s", q_path)); 1409 srv_log(xs_fmt("activitypub_post_handler JSON error %s", q_path));
1410
1411 *body = xs_str_new("JSON error");
1412 *ctype = "text/plain";
1392 status = 400; 1413 status = 400;
1393 } 1414 }
1394 1415
@@ -1417,6 +1438,9 @@ int activitypub_post_handler(d_char *req, char *q_path,
1417 1438
1418 if (strcmp(s2, v) != 0) { 1439 if (strcmp(s2, v) != 0) {
1419 srv_log(xs_fmt("digest check FAILED")); 1440 srv_log(xs_fmt("digest check FAILED"));
1441
1442 *body = xs_str_new("bad digest");
1443 *ctype = "text/plain";
1420 status = 400; 1444 status = 400;
1421 } 1445 }
1422 } 1446 }