diff options
author | default <nobody@localhost> | 2023-07-13 21:01:15 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2023-07-13 21:01:15 +0200 |
commit | 2caeb550b94c8b08d9eebb62f6f05e14df15e666 (patch) | |
tree | b4d9bbd0cced4271caecce940800a5303edd7d84 /activitypub.c | |
parent | a05aa969d0cd2efbd08bbeda69544ceb8f26a388 (diff) |
Added support for the 'Page' ActivityPub object.
So that you can follow and interact with lemmy channels.
Diffstat (limited to 'activitypub.c')
-rw-r--r-- | activitypub.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/activitypub.c b/activitypub.c index 4843067..b3c7367 100644 --- a/activitypub.c +++ b/activitypub.c @@ -152,18 +152,19 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level) int status = 0; if (!xs_is_null(*id)) { - xs *object = NULL; + xs *msg = NULL; /* is the object already there? */ - if (!valid_status(object_get(*id, &object))) { + if (!valid_status(object_get(*id, &msg))) { /* no; download it */ - status = activitypub_request(snac, *id, &object); + status = activitypub_request(snac, *id, &msg); if (valid_status(status)) { - char *type = xs_dict_get(object, "type"); + xs_dict *object = msg; + const char *type = xs_dict_get(object, "type"); /* get the id again from the object, as it may be different */ - char *nid = xs_dict_get(object, "id"); + const char *nid = xs_dict_get(object, "id"); if (wrk && strcmp(nid, *id) != 0) { snac_debug(snac, 1, @@ -173,8 +174,21 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level) *id = *wrk; } - if (!xs_is_null(type) && strcmp(type, "Note") == 0) { - char *actor = xs_dict_get(object, "attributedTo"); + if (xs_is_null(type)) + type = "(null)"; + + srv_debug(0, xs_fmt("timeline_request type %s '%s'", *id, type)); + + if (strcmp(type, "Create") == 0) { + /* some software like lemmy nest Announce + Create + Note */ + if (!xs_is_null(object = xs_dict_get(object, "object"))) + type = xs_dict_get(object, "type"); + else + type = "(null)"; + } + + if (strcmp(type, "Note") == 0 || strcmp(type, "Page") == 0) { + const char *actor = xs_dict_get(object, "attributedTo"); /* request (and drop) the actor for this entry */ if (!xs_is_null(actor)) |