commit bebb2c7
Stefano Marinelli
·
2025-10-21 10:29:56 +0000 UTC
parent 2d433af
Instead of comparing the output status with == 200, it's better to check using valid_status()
2 files changed,
+5,
-5
+3,
-3
1@@ -141,7 +141,7 @@ static xs_dict *actor_get_collections(snac *user, xs_dict *actor, int throttle)
2 /* only fetch followers count if not already present */
3 if (xs_type(existing_followers) != XSTYPE_NUMBER && !xs_is_null(followers_url)) {
4 xs *followers_coll = NULL;
5- if (activitypub_request(user, followers_url, &followers_coll) == 200) {
6+ if (valid_status(activitypub_request(user, followers_url, &followers_coll))) {
7 const xs_number *total = xs_dict_get(followers_coll, "totalItems");
8 if (xs_type(total) == XSTYPE_NUMBER) {
9 xs *total_copy = xs_dup(total);
10@@ -156,7 +156,7 @@ static xs_dict *actor_get_collections(snac *user, xs_dict *actor, int throttle)
11 /* only fetch following count if not already present */
12 if (xs_type(existing_following) != XSTYPE_NUMBER && !xs_is_null(following_url)) {
13 xs *following_coll = NULL;
14- if (activitypub_request(user, following_url, &following_coll) == 200) {
15+ if (valid_status(activitypub_request(user, following_url, &following_coll))) {
16 const xs_number *total = xs_dict_get(following_coll, "totalItems");
17 if (xs_type(total) == XSTYPE_NUMBER) {
18 xs *total_copy = xs_dup(total);
19@@ -171,7 +171,7 @@ static xs_dict *actor_get_collections(snac *user, xs_dict *actor, int throttle)
20 /* only fetch statuses count if not already present */
21 if (xs_type(existing_statuses) != XSTYPE_NUMBER && !xs_is_null(outbox_url)) {
22 xs *outbox_coll = NULL;
23- if (activitypub_request(user, outbox_url, &outbox_coll) == 200) {
24+ if (valid_status(activitypub_request(user, outbox_url, &outbox_coll))) {
25 const xs_number *total = xs_dict_get(outbox_coll, "totalItems");
26 if (xs_type(total) == XSTYPE_NUMBER) {
27 xs *total_copy = xs_dup(total);
+2,
-2
1@@ -569,7 +569,7 @@ static const xs_list *get_collection_items(snac *snac, const char *collection_ur
2 const xs_list *items = NULL;
3 xs_dict *collection = NULL;
4
5- if (activitypub_request(snac, collection_url, &collection) == 200) {
6+ if (valid_status(activitypub_request(snac, collection_url, &collection))) {
7 /* check if items are directly embedded */
8 items = xs_dict_get(collection, "orderedItems");
9 if (xs_is_null(items))
10@@ -586,7 +586,7 @@ static const xs_list *get_collection_items(snac *snac, const char *collection_ur
11 const char *first_url = xs_dict_get(collection, "first");
12 if (!xs_is_null(first_url)) {
13 xs_dict *first_page = NULL;
14- if (activitypub_request(snac, first_url, &first_page) == 200) {
15+ if (valid_status(activitypub_request(snac, first_url, &first_page))) {
16 items = xs_dict_get(first_page, "orderedItems");
17 if (xs_is_null(items))
18 items = xs_dict_get(first_page, "items");