summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Stefano Marinelli2025-10-21 12:29:56 +0200
committerGravatar Stefano Marinelli2025-10-21 12:29:56 +0200
commitbebb2c7439ecdef0266f47dc4b05ab093259e63b (patch)
tree9b7c90f92bf89a3474eaacb3bcc0e5ec1fbd4b65
parentEnhances Mastodon API compatibility by adding support for displaying remote u... (diff)
downloadpenes-snac2-bebb2c7439ecdef0266f47dc4b05ab093259e63b.tar.gz
penes-snac2-bebb2c7439ecdef0266f47dc4b05ab093259e63b.tar.xz
penes-snac2-bebb2c7439ecdef0266f47dc4b05ab093259e63b.zip
Instead of comparing the output status with == 200, it's better to check using valid_status()
-rw-r--r--activitypub.c6
-rw-r--r--mastoapi.c4
2 files changed, 5 insertions, 5 deletions
diff --git a/activitypub.c b/activitypub.c
index 117bbc9..2d53cbe 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -141,7 +141,7 @@ static xs_dict *actor_get_collections(snac *user, xs_dict *actor, int throttle)
141 /* only fetch followers count if not already present */ 141 /* only fetch followers count if not already present */
142 if (xs_type(existing_followers) != XSTYPE_NUMBER && !xs_is_null(followers_url)) { 142 if (xs_type(existing_followers) != XSTYPE_NUMBER && !xs_is_null(followers_url)) {
143 xs *followers_coll = NULL; 143 xs *followers_coll = NULL;
144 if (activitypub_request(user, followers_url, &followers_coll) == 200) { 144 if (valid_status(activitypub_request(user, followers_url, &followers_coll))) {
145 const xs_number *total = xs_dict_get(followers_coll, "totalItems"); 145 const xs_number *total = xs_dict_get(followers_coll, "totalItems");
146 if (xs_type(total) == XSTYPE_NUMBER) { 146 if (xs_type(total) == XSTYPE_NUMBER) {
147 xs *total_copy = xs_dup(total); 147 xs *total_copy = xs_dup(total);
@@ -156,7 +156,7 @@ static xs_dict *actor_get_collections(snac *user, xs_dict *actor, int throttle)
156 /* only fetch following count if not already present */ 156 /* only fetch following count if not already present */
157 if (xs_type(existing_following) != XSTYPE_NUMBER && !xs_is_null(following_url)) { 157 if (xs_type(existing_following) != XSTYPE_NUMBER && !xs_is_null(following_url)) {
158 xs *following_coll = NULL; 158 xs *following_coll = NULL;
159 if (activitypub_request(user, following_url, &following_coll) == 200) { 159 if (valid_status(activitypub_request(user, following_url, &following_coll))) {
160 const xs_number *total = xs_dict_get(following_coll, "totalItems"); 160 const xs_number *total = xs_dict_get(following_coll, "totalItems");
161 if (xs_type(total) == XSTYPE_NUMBER) { 161 if (xs_type(total) == XSTYPE_NUMBER) {
162 xs *total_copy = xs_dup(total); 162 xs *total_copy = xs_dup(total);
@@ -171,7 +171,7 @@ static xs_dict *actor_get_collections(snac *user, xs_dict *actor, int throttle)
171 /* only fetch statuses count if not already present */ 171 /* only fetch statuses count if not already present */
172 if (xs_type(existing_statuses) != XSTYPE_NUMBER && !xs_is_null(outbox_url)) { 172 if (xs_type(existing_statuses) != XSTYPE_NUMBER && !xs_is_null(outbox_url)) {
173 xs *outbox_coll = NULL; 173 xs *outbox_coll = NULL;
174 if (activitypub_request(user, outbox_url, &outbox_coll) == 200) { 174 if (valid_status(activitypub_request(user, outbox_url, &outbox_coll))) {
175 const xs_number *total = xs_dict_get(outbox_coll, "totalItems"); 175 const xs_number *total = xs_dict_get(outbox_coll, "totalItems");
176 if (xs_type(total) == XSTYPE_NUMBER) { 176 if (xs_type(total) == XSTYPE_NUMBER) {
177 xs *total_copy = xs_dup(total); 177 xs *total_copy = xs_dup(total);
diff --git a/mastoapi.c b/mastoapi.c
index 119a715..94912f1 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -569,7 +569,7 @@ static const xs_list *get_collection_items(snac *snac, const char *collection_ur
569 const xs_list *items = NULL; 569 const xs_list *items = NULL;
570 xs_dict *collection = NULL; 570 xs_dict *collection = NULL;
571 571
572 if (activitypub_request(snac, collection_url, &collection) == 200) { 572 if (valid_status(activitypub_request(snac, collection_url, &collection))) {
573 /* check if items are directly embedded */ 573 /* check if items are directly embedded */
574 items = xs_dict_get(collection, "orderedItems"); 574 items = xs_dict_get(collection, "orderedItems");
575 if (xs_is_null(items)) 575 if (xs_is_null(items))
@@ -586,7 +586,7 @@ static const xs_list *get_collection_items(snac *snac, const char *collection_ur
586 const char *first_url = xs_dict_get(collection, "first"); 586 const char *first_url = xs_dict_get(collection, "first");
587 if (!xs_is_null(first_url)) { 587 if (!xs_is_null(first_url)) {
588 xs_dict *first_page = NULL; 588 xs_dict *first_page = NULL;
589 if (activitypub_request(snac, first_url, &first_page) == 200) { 589 if (valid_status(activitypub_request(snac, first_url, &first_page))) {
590 items = xs_dict_get(first_page, "orderedItems"); 590 items = xs_dict_get(first_page, "orderedItems");
591 if (xs_is_null(items)) 591 if (xs_is_null(items))
592 items = xs_dict_get(first_page, "items"); 592 items = xs_dict_get(first_page, "items");