commit 3df33c845d2a504017065505d91a5ad1c0593408
parent c181c57f5611a477f11b8be375263ef9fed638dd
Author: default <nobody@localhost>
Date: Fri, 23 Sep 2022 23:49:09 +0200
More ActivityPub work.
Diffstat:
1 file changed, 45 insertions(+), 0 deletions(-)
diff --git 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;
}