diff options
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) | |||
| 73 | 73 | ||
| 74 | return status; | 74 | return status; |
| 75 | } | 75 | } |
| 76 | |||
| 77 | |||
| 78 | int send_to_inbox(snac *snac, char *inbox, char *msg, d_char **payload, int *p_size) | ||
| 79 | /* sends a message to an Inbox */ | ||
| 80 | { | ||
| 81 | int status; | ||
| 82 | d_char *response; | ||
| 83 | |||
| 84 | response = http_signed_request(snac, "POST", inbox, | ||
| 85 | NULL, msg, strlen(msg), &status, payload, p_size); | ||
| 86 | |||
| 87 | free(response); | ||
| 88 | |||
| 89 | return status; | ||
| 90 | } | ||
| 91 | |||
| 92 | |||
| 93 | int send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_size) | ||
| 94 | /* sends a message to an actor */ | ||
| 95 | { | ||
| 96 | int status; | ||
| 97 | xs *data = NULL; | ||
| 98 | |||
| 99 | /* resolve the actor first */ | ||
| 100 | status = actor_request(snac, actor, &data); | ||
| 101 | |||
| 102 | if (valid_status(status)) { | ||
| 103 | char *inbox = xs_dict_get(data, "inbox"); | ||
| 104 | |||
| 105 | if (inbox != NULL) | ||
| 106 | status = send_to_inbox(snac, inbox, msg, payload, p_size); | ||
| 107 | else | ||
| 108 | status = 400; | ||
| 109 | } | ||
| 110 | |||
| 111 | return status; | ||
| 112 | } | ||