mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 05:15:04 +00:00
New functions send_to_inbox() and send_to_actor().
This commit is contained in:
parent
6586be50a0
commit
cf59d68491
3 changed files with 40 additions and 1 deletions
|
@ -73,3 +73,40 @@ int actor_request(snac *snac, char *actor, d_char **data)
|
|||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_size)
|
||||
/* sends a message to an Inbox */
|
||||
{
|
||||
int status;
|
||||
d_char *response;
|
||||
|
||||
response = http_signed_request(snac, "POST", inbox,
|
||||
NULL, msg, strlen(msg), &status, payload, p_size);
|
||||
|
||||
free(response);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
int send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_size)
|
||||
/* sends a message to an actor */
|
||||
{
|
||||
int status;
|
||||
xs *data = NULL;
|
||||
|
||||
/* resolve the actor first */
|
||||
status = actor_request(snac, actor, &data);
|
||||
|
||||
if (valid_status(status)) {
|
||||
char *inbox = xs_dict_get(data, "inbox");
|
||||
|
||||
if (inbox != NULL)
|
||||
status = send_to_inbox(snac, inbox, msg, payload, p_size);
|
||||
else
|
||||
status = 400;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
2
data.c
2
data.c
|
@ -724,7 +724,7 @@ int actor_get(snac *snac, char *actor, d_char **data)
|
|||
fclose(f);
|
||||
}
|
||||
|
||||
status = 110; /* "Response Is Stale" */
|
||||
status = 205; /* "205: Reset Content" "110: Response Is Stale" */
|
||||
}
|
||||
else {
|
||||
/* it's still valid */
|
||||
|
|
2
snac.h
2
snac.h
|
@ -82,3 +82,5 @@ int webfinger_get_handler(d_char *req, char *q_path,
|
|||
|
||||
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 send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_size);
|
||||
|
|
Loading…
Reference in a new issue