diff options
Diffstat (limited to 'activitypub.c')
| -rw-r--r-- | activitypub.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/activitypub.c b/activitypub.c index 025c48c..5ab7a96 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -773,6 +773,12 @@ int activitypub_get_handler(d_char *req, char *q_path, | |||
| 773 | } | 773 | } |
| 774 | else | 774 | else |
| 775 | if (xs_startswith(p_path, "p/")) { | 775 | if (xs_startswith(p_path, "p/")) { |
| 776 | xs *id = xs_fmt("%s/%s", snac.actor, p_path); | ||
| 777 | |||
| 778 | if ((msg = timeline_find(&snac, id)) != NULL) | ||
| 779 | msg = xs_dict_del(msg, "_snac"); | ||
| 780 | else | ||
| 781 | status = 404; | ||
| 776 | } | 782 | } |
| 777 | else | 783 | else |
| 778 | status = 404; | 784 | status = 404; |
| @@ -782,6 +788,8 @@ int activitypub_get_handler(d_char *req, char *q_path, | |||
| 782 | *b_size = strlen(*body); | 788 | *b_size = strlen(*body); |
| 783 | } | 789 | } |
| 784 | 790 | ||
| 791 | snac_debug(&snac, 1, xs_fmt("activitypub_get_handler serving %s %d", q_path, status)); | ||
| 792 | |||
| 785 | user_free(&snac); | 793 | user_free(&snac); |
| 786 | 794 | ||
| 787 | return status; | 795 | return status; |
| @@ -836,18 +844,18 @@ int activitypub_post_handler(d_char *req, char *q_path, | |||
| 836 | xs *s1 = xs_sha256_base64(payload, p_size); | 844 | xs *s1 = xs_sha256_base64(payload, p_size); |
| 837 | xs *s2 = xs_fmt("SHA-256=%s", s1); | 845 | xs *s2 = xs_fmt("SHA-256=%s", s1); |
| 838 | 846 | ||
| 839 | if (strcmp(s2, v) == 0) | 847 | if (strcmp(s2, v) != 0) { |
| 840 | srv_log(xs_fmt("digest check OK")); | ||
| 841 | else | ||
| 842 | srv_log(xs_fmt("digest check FAILED")); | 848 | srv_log(xs_fmt("digest check FAILED")); |
| 849 | status = 400; | ||
| 850 | } | ||
| 843 | } | 851 | } |
| 844 | 852 | ||
| 845 | enqueue_input(&snac, msg, req); | 853 | if (valid_status(status)) { |
| 854 | enqueue_input(&snac, msg, req); | ||
| 855 | *ctype = "application/activity+json"; | ||
| 856 | } | ||
| 846 | 857 | ||
| 847 | user_free(&snac); | 858 | user_free(&snac); |
| 848 | 859 | ||
| 849 | if (valid_status(status)) | ||
| 850 | *ctype = "application/activity+json"; | ||
| 851 | |||
| 852 | return status; | 860 | return status; |
| 853 | } | 861 | } |