summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-09-25 07:58:25 +0200
committerdefault <nobody@localhost>2022-09-25 07:58:25 +0200
commit5792ef5d24bd58f5c74a37c43d80720c46a6758a (patch)
tree924c45037ad69eed1b76bb938e026df727bb1fe7 /activitypub.c
parentb070d2d8f88866bf83103c34c4d86352c6b74e8d (diff)
Process 'Create' messages (untested).
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/activitypub.c b/activitypub.c
index ec1d820..a6fa645 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -173,22 +173,51 @@ d_char *msg_update(snac *snac, char *object)
void process_message(snac *snac, char *msg, char *req)
/* processes an ActivityPub message from the input queue */
{
- /* they exist, were checked previously */
- char *actor = xs_dict_get(msg, "actor");
- char *type = xs_dict_get(msg, "type");
+ /* actor and type exist, were checked previously */
+ char *actor = xs_dict_get(msg, "actor");
+ char *type = xs_dict_get(msg, "type");
+
+ char *object, *utype;
+
+ object = xs_dict_get(msg, "object");
+ if (object != NULL && xs_type(object) == XSTYPE_SOD)
+ utype = xs_dict_get(object, "type");
+ else
+ utype = "(null)";
/* check the signature */
/* ... */
+/*
if (strcmp(type, "Follow") == 0) {
}
else
if (strcmp(type, "Undo") == 0) {
}
else
+*/
if (strcmp(type, "Create") == 0) {
+ if (strcmp(utype, "Note") == 0) {
+ if (is_muted(snac, actor))
+ snac_log(snac, xs_fmt("ignored 'Note' from muted actor %s", actor));
+ else {
+ char *id = xs_dict_get(object, "id");
+ char *in_reply_to = xs_dict_get(object, "inReplyTo");
+
+ if (in_reply_to != NULL) {
+ /* recursively download ancestors */
+ /* ... */
+ }
+
+ snac_log(snac, xs_fmt("new 'Note' %s %s", actor, id));
+ timeline_add(snac, id, msg, in_reply_to);
+ }
+ }
+ else
+ snac_debug(snac, 1, xs_fmt("ignored 'Create' for object type '%s'", utype));
}
else
+/*
if (strcmp(type, "Accept") == 0) {
}
else
@@ -201,6 +230,7 @@ void process_message(snac *snac, char *msg, char *req)
if (strcmp(type, "Delete") == 0) {
}
else
+*/
snac_debug(snac, 1, xs_fmt("process_message type '%s' ignored", type));
}