commit 297b82c

default  ·  2023-06-15 02:19:09 +0000 UTC
parent e97092c
following_list() creates links to the actors if they don't exist.
1 files changed,  +13, -3
M data.c
M data.c
+13, -3
 1@@ -1256,13 +1256,23 @@ xs_list *following_list(snac *snac)
 2                 xs *o = xs_json_loads(j);
 3 
 4                 if (o != NULL) {
 5-                    char *type = xs_dict_get(o, "type");
 6+                    const char *type = xs_dict_get(o, "type");
 7 
 8                     if (!xs_is_null(type) && strcmp(type, "Accept") == 0) {
 9-                        char *actor = xs_dict_get(o, "actor");
10+                        const char *actor = xs_dict_get(o, "actor");
11 
12-                        if (!xs_is_null(actor))
13+                        if (!xs_is_null(actor)) {
14                             list = xs_list_append(list, actor);
15+
16+                            /* check if there is a link to the actor object */
17+                            xs *v2 = xs_replace(v, ".json", "");
18+
19+                            if (mtime(v2) == 0.0) {
20+                                /* no; add a link to it */
21+                                xs *actor_fn = _object_fn(actor);
22+                                link(actor_fn, v2);
23+                            }
24+                        }
25                     }
26                 }
27             }