diff options
author | default <nobody@localhost> | 2022-09-23 19:07:45 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2022-09-23 19:07:45 +0200 |
commit | cf59d68491bb4bf0954e8370354ba34994b6436f (patch) | |
tree | 9429b80983f243964bda9db6f2533bb1fcf3b714 /activitypub.c | |
parent | 6586be50a0297de0e9b7e6cd66ce3b25eccf7e5c (diff) |
New functions send_to_inbox() and send_to_actor().
Diffstat (limited to 'activitypub.c')
-rw-r--r-- | activitypub.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c index f9144a6..5d54833 100644 --- a/activitypub.c +++ b/activitypub.c @@ -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; +} |