diff options
| -rw-r--r-- | activitypub.c | 20 | ||||
| -rw-r--r-- | httpd.c | 6 | ||||
| -rw-r--r-- | snac.h | 12 |
3 files changed, 30 insertions, 8 deletions
diff --git a/activitypub.c b/activitypub.c index 5c98389..8e17daa 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -160,14 +160,16 @@ int timeline_request(snac *snac, char **id, d_char **wrk) | |||
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | 162 | ||
| 163 | int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_size, int timeout) | 163 | int send_to_inbox_raw(const char *keyid, const char *seckey, |
| 164 | const xs_str *inbox, const xs_dict *msg, | ||
| 165 | xs_val **payload, int *p_size, int timeout) | ||
| 164 | /* sends a message to an Inbox */ | 166 | /* sends a message to an Inbox */ |
| 165 | { | 167 | { |
| 166 | int status; | 168 | int status; |
| 167 | d_char *response; | 169 | xs_dict *response; |
| 168 | xs *j_msg = xs_json_dumps_pp(msg, 4); | 170 | xs *j_msg = xs_json_dumps_pp((xs_dict *)msg, 4); |
| 169 | 171 | ||
| 170 | response = http_signed_request(snac, "POST", inbox, | 172 | response = http_signed_request_raw(keyid, seckey, "POST", inbox, |
| 171 | NULL, j_msg, strlen(j_msg), &status, payload, p_size, timeout); | 173 | NULL, j_msg, strlen(j_msg), &status, payload, p_size, timeout); |
| 172 | 174 | ||
| 173 | xs_free(response); | 175 | xs_free(response); |
| @@ -176,6 +178,16 @@ int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_s | |||
| 176 | } | 178 | } |
| 177 | 179 | ||
| 178 | 180 | ||
| 181 | int send_to_inbox(snac *snac, const xs_str *inbox, const xs_dict *msg, | ||
| 182 | xs_val **payload, int *p_size, int timeout) | ||
| 183 | /* sends a message to an Inbox */ | ||
| 184 | { | ||
| 185 | char *seckey = xs_dict_get(snac->key, "secret"); | ||
| 186 | |||
| 187 | return send_to_inbox_raw(snac->actor, seckey, inbox, msg, payload, p_size, timeout); | ||
| 188 | } | ||
| 189 | |||
| 190 | |||
| 179 | d_char *get_actor_inbox(snac *snac, char *actor) | 191 | d_char *get_actor_inbox(snac *snac, char *actor) |
| 180 | /* gets an actor's inbox */ | 192 | /* gets an actor's inbox */ |
| 181 | { | 193 | { |
| @@ -295,14 +295,14 @@ static void *job_thread(void *arg) | |||
| 295 | { | 295 | { |
| 296 | long long pid = (long long)arg; | 296 | long long pid = (long long)arg; |
| 297 | 297 | ||
| 298 | srv_debug(1, xs_fmt("job thread %ld started", pid)); | 298 | srv_debug(0, xs_fmt("job thread %ld started", pid)); |
| 299 | 299 | ||
| 300 | for (;;) { | 300 | for (;;) { |
| 301 | xs *job = NULL; | 301 | xs *job = NULL; |
| 302 | 302 | ||
| 303 | job_wait(&job); | 303 | job_wait(&job); |
| 304 | 304 | ||
| 305 | srv_debug(1, xs_fmt("job thread %ld wake up", pid)); | 305 | srv_debug(0, xs_fmt("job thread %ld wake up", pid)); |
| 306 | 306 | ||
| 307 | if (job == NULL) | 307 | if (job == NULL) |
| 308 | break; | 308 | break; |
| @@ -322,7 +322,7 @@ static void *job_thread(void *arg) | |||
| 322 | } | 322 | } |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | srv_debug(1, xs_fmt("job thread %ld stopped", pid)); | 325 | srv_debug(0, xs_fmt("job thread %ld stopped", pid)); |
| 326 | 326 | ||
| 327 | return NULL; | 327 | return NULL; |
| 328 | } | 328 | } |
| @@ -142,6 +142,12 @@ xs_dict *dequeue(const char *fn); | |||
| 142 | void purge(snac *snac); | 142 | void purge(snac *snac); |
| 143 | void purge_all(void); | 143 | void purge_all(void); |
| 144 | 144 | ||
| 145 | xs_dict *http_signed_request_raw(const char *keyid, const char *seckey, | ||
| 146 | const char *method, const char *url, | ||
| 147 | xs_dict *headers, | ||
| 148 | const char *body, int b_size, | ||
| 149 | int *status, xs_str **payload, int *p_size, | ||
| 150 | int timeout); | ||
| 145 | xs_dict *http_signed_request(snac *snac, const char *method, const char *url, | 151 | xs_dict *http_signed_request(snac *snac, const char *method, const char *url, |
| 146 | xs_dict *headers, | 152 | xs_dict *headers, |
| 147 | const char *body, int b_size, | 153 | const char *body, int b_size, |
| @@ -168,7 +174,11 @@ d_char *msg_update(snac *snac, char *object); | |||
| 168 | 174 | ||
| 169 | int activitypub_request(snac *snac, char *url, d_char **data); | 175 | int activitypub_request(snac *snac, char *url, d_char **data); |
| 170 | int actor_request(snac *snac, char *actor, d_char **data); | 176 | int actor_request(snac *snac, char *actor, d_char **data); |
| 171 | int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_size, int timeout); | 177 | int send_to_inbox_raw(const char *keyid, const char *seckey, |
| 178 | const xs_str *inbox, const xs_dict *msg, | ||
| 179 | xs_val **payload, int *p_size, int timeout); | ||
| 180 | int send_to_inbox(snac *snac, const xs_str *inbox, const xs_dict *msg, | ||
| 181 | xs_val **payload, int *p_size, int timeout); | ||
| 172 | d_char *get_actor_inbox(snac *snac, char *actor); | 182 | d_char *get_actor_inbox(snac *snac, char *actor); |
| 173 | int send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_size, int timeout); | 183 | int send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_size, int timeout); |
| 174 | int is_msg_public(snac *snac, char *msg); | 184 | int is_msg_public(snac *snac, char *msg); |