mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
New function send_to_inbox_raw().
This commit is contained in:
parent
67f2d4318d
commit
3ddf76c2aa
3 changed files with 30 additions and 8 deletions
|
@ -160,14 +160,16 @@ int timeline_request(snac *snac, char **id, d_char **wrk)
|
|||
}
|
||||
|
||||
|
||||
int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_size, int timeout)
|
||||
int send_to_inbox_raw(const char *keyid, const char *seckey,
|
||||
const xs_str *inbox, const xs_dict *msg,
|
||||
xs_val **payload, int *p_size, int timeout)
|
||||
/* sends a message to an Inbox */
|
||||
{
|
||||
int status;
|
||||
d_char *response;
|
||||
xs *j_msg = xs_json_dumps_pp(msg, 4);
|
||||
xs_dict *response;
|
||||
xs *j_msg = xs_json_dumps_pp((xs_dict *)msg, 4);
|
||||
|
||||
response = http_signed_request(snac, "POST", inbox,
|
||||
response = http_signed_request_raw(keyid, seckey, "POST", inbox,
|
||||
NULL, j_msg, strlen(j_msg), &status, payload, p_size, timeout);
|
||||
|
||||
xs_free(response);
|
||||
|
@ -176,6 +178,16 @@ int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_s
|
|||
}
|
||||
|
||||
|
||||
int send_to_inbox(snac *snac, const xs_str *inbox, const xs_dict *msg,
|
||||
xs_val **payload, int *p_size, int timeout)
|
||||
/* sends a message to an Inbox */
|
||||
{
|
||||
char *seckey = xs_dict_get(snac->key, "secret");
|
||||
|
||||
return send_to_inbox_raw(snac->actor, seckey, inbox, msg, payload, p_size, timeout);
|
||||
}
|
||||
|
||||
|
||||
d_char *get_actor_inbox(snac *snac, char *actor)
|
||||
/* gets an actor's inbox */
|
||||
{
|
||||
|
|
6
httpd.c
6
httpd.c
|
@ -295,14 +295,14 @@ static void *job_thread(void *arg)
|
|||
{
|
||||
long long pid = (long long)arg;
|
||||
|
||||
srv_debug(1, xs_fmt("job thread %ld started", pid));
|
||||
srv_debug(0, xs_fmt("job thread %ld started", pid));
|
||||
|
||||
for (;;) {
|
||||
xs *job = NULL;
|
||||
|
||||
job_wait(&job);
|
||||
|
||||
srv_debug(1, xs_fmt("job thread %ld wake up", pid));
|
||||
srv_debug(0, xs_fmt("job thread %ld wake up", pid));
|
||||
|
||||
if (job == NULL)
|
||||
break;
|
||||
|
@ -322,7 +322,7 @@ static void *job_thread(void *arg)
|
|||
}
|
||||
}
|
||||
|
||||
srv_debug(1, xs_fmt("job thread %ld stopped", pid));
|
||||
srv_debug(0, xs_fmt("job thread %ld stopped", pid));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
12
snac.h
12
snac.h
|
@ -142,6 +142,12 @@ xs_dict *dequeue(const char *fn);
|
|||
void purge(snac *snac);
|
||||
void purge_all(void);
|
||||
|
||||
xs_dict *http_signed_request_raw(const char *keyid, const char *seckey,
|
||||
const char *method, const char *url,
|
||||
xs_dict *headers,
|
||||
const char *body, int b_size,
|
||||
int *status, xs_str **payload, int *p_size,
|
||||
int timeout);
|
||||
xs_dict *http_signed_request(snac *snac, const char *method, const char *url,
|
||||
xs_dict *headers,
|
||||
const char *body, int b_size,
|
||||
|
@ -168,7 +174,11 @@ d_char *msg_update(snac *snac, char *object);
|
|||
|
||||
int activitypub_request(snac *snac, char *url, d_char **data);
|
||||
int actor_request(snac *snac, char *actor, d_char **data);
|
||||
int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_size, int timeout);
|
||||
int send_to_inbox_raw(const char *keyid, const char *seckey,
|
||||
const xs_str *inbox, const xs_dict *msg,
|
||||
xs_val **payload, int *p_size, int timeout);
|
||||
int send_to_inbox(snac *snac, const xs_str *inbox, const xs_dict *msg,
|
||||
xs_val **payload, int *p_size, int timeout);
|
||||
d_char *get_actor_inbox(snac *snac, char *actor);
|
||||
int send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_size, int timeout);
|
||||
int is_msg_public(snac *snac, char *msg);
|
||||
|
|
Loading…
Reference in a new issue