summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-09-23 23:49:09 +0200
committerdefault <nobody@localhost>2022-09-23 23:49:09 +0200
commit3df33c845d2a504017065505d91a5ad1c0593408 (patch)
tree77bf160814954311d659c5c995a5af4438071a26 /activitypub.c
parentc181c57f5611a477f11b8be375263ef9fed638dd (diff)
More ActivityPub work.
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/activitypub.c b/activitypub.c
index 4a7c247..8ee7b3d 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -115,6 +115,38 @@ int send_to_actor(snac *snac, char *actor, char *msg, d_char **payload, int *p_s
}
+void process_message(snac *snac, char *msg)
+/* processes an ActivityPub message */
+{
+ /* they exist, were checked previously */
+ char *actor = xs_dict_get(msg, "actor");
+ char *type = xs_dict_get(msg, "type");
+
+ if (strcmp(type, "Follow") == 0) {
+ }
+ else
+ if (strcmp(type, "Undo") == 0) {
+ }
+ else
+ if (strcmp(type, "Create") == 0) {
+ }
+ else
+ if (strcmp(type, "Accept") == 0) {
+ }
+ else
+ if (strcmp(type, "Like") == 0 || strcmp(type, "Announce") == 0) {
+ }
+ else
+ if (strcmp(type, "Update") == 0) {
+ }
+ else
+ if (strcmp(type, "Delete") == 0) {
+ }
+ else
+ snac_debug(snac, 1, xs_fmt("process_message type '%s' ignored", type));
+}
+
+
void process_queue(snac *snac)
/* processes the queue */
{
@@ -152,6 +184,13 @@ void process_queue(snac *snac)
}
}
}
+ else
+ if (strcmp(type, "input") == 0) {
+ /* process the message */
+ char *msg = xs_dict_get(q_item, "object");
+
+ process_message(snac, msg);
+ }
}
}
@@ -253,6 +292,9 @@ int activitypub_post_handler(d_char *req, char *q_path,
return 404;
}
+ /* signature checking should happen here */
+ /* ... */
+
/* decode */
xs *msg = xs_json_loads(payload);
@@ -265,5 +307,8 @@ int activitypub_post_handler(d_char *req, char *q_path,
user_free(&snac);
+ if (valid_status(status))
+ *ctype = "application/activity+json";
+
return status;
}