summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c37
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;
+}