diff options
| author | 2023-07-13 21:01:15 +0200 | |
|---|---|---|
| committer | 2023-07-13 21:01:15 +0200 | |
| commit | 2caeb550b94c8b08d9eebb62f6f05e14df15e666 (patch) | |
| tree | b4d9bbd0cced4271caecce940800a5303edd7d84 /activitypub.c | |
| parent | Added a maximum level of recursion to timeline_request(). (diff) | |
| download | snac2-2caeb550b94c8b08d9eebb62f6f05e14df15e666.tar.gz snac2-2caeb550b94c8b08d9eebb62f6f05e14df15e666.tar.xz snac2-2caeb550b94c8b08d9eebb62f6f05e14df15e666.zip | |
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) | |||
| 152 | int status = 0; | 152 | int status = 0; |
| 153 | 153 | ||
| 154 | if (!xs_is_null(*id)) { | 154 | if (!xs_is_null(*id)) { |
| 155 | xs *object = NULL; | 155 | xs *msg = NULL; |
| 156 | 156 | ||
| 157 | /* is the object already there? */ | 157 | /* is the object already there? */ |
| 158 | if (!valid_status(object_get(*id, &object))) { | 158 | if (!valid_status(object_get(*id, &msg))) { |
| 159 | /* no; download it */ | 159 | /* no; download it */ |
| 160 | status = activitypub_request(snac, *id, &object); | 160 | status = activitypub_request(snac, *id, &msg); |
| 161 | 161 | ||
| 162 | if (valid_status(status)) { | 162 | if (valid_status(status)) { |
| 163 | char *type = xs_dict_get(object, "type"); | 163 | xs_dict *object = msg; |
| 164 | const char *type = xs_dict_get(object, "type"); | ||
| 164 | 165 | ||
| 165 | /* get the id again from the object, as it may be different */ | 166 | /* get the id again from the object, as it may be different */ |
| 166 | char *nid = xs_dict_get(object, "id"); | 167 | const char *nid = xs_dict_get(object, "id"); |
| 167 | 168 | ||
| 168 | if (wrk && strcmp(nid, *id) != 0) { | 169 | if (wrk && strcmp(nid, *id) != 0) { |
| 169 | snac_debug(snac, 1, | 170 | snac_debug(snac, 1, |
| @@ -173,8 +174,21 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level) | |||
| 173 | *id = *wrk; | 174 | *id = *wrk; |
| 174 | } | 175 | } |
| 175 | 176 | ||
| 176 | if (!xs_is_null(type) && strcmp(type, "Note") == 0) { | 177 | if (xs_is_null(type)) |
| 177 | char *actor = xs_dict_get(object, "attributedTo"); | 178 | type = "(null)"; |
| 179 | |||
| 180 | srv_debug(0, xs_fmt("timeline_request type %s '%s'", *id, type)); | ||
| 181 | |||
| 182 | if (strcmp(type, "Create") == 0) { | ||
| 183 | /* some software like lemmy nest Announce + Create + Note */ | ||
| 184 | if (!xs_is_null(object = xs_dict_get(object, "object"))) | ||
| 185 | type = xs_dict_get(object, "type"); | ||
| 186 | else | ||
| 187 | type = "(null)"; | ||
| 188 | } | ||
| 189 | |||
| 190 | if (strcmp(type, "Note") == 0 || strcmp(type, "Page") == 0) { | ||
| 191 | const char *actor = xs_dict_get(object, "attributedTo"); | ||
| 178 | 192 | ||
| 179 | /* request (and drop) the actor for this entry */ | 193 | /* request (and drop) the actor for this entry */ |
| 180 | if (!xs_is_null(actor)) | 194 | if (!xs_is_null(actor)) |