commit 263e239
default
·
2024-02-15 16:34:46 +0000 UTC
parent 2afcb4b
Moved verified links to its own json file.
4 files changed,
+17,
-8
M
data.c
+9,
-0
1@@ -146,6 +146,7 @@ void user_free(snac *snac)
2 xs_free(snac->config);
3 xs_free(snac->config_o);
4 xs_free(snac->key);
5+ xs_free(snac->links);
6 xs_free(snac->actor);
7 xs_free(snac->md5);
8 }
9@@ -233,6 +234,14 @@ int user_open(snac *user, const char *uid)
10 }
11 else
12 srv_debug(2, xs_fmt("error opening '%s' %d", cfg_file, errno));
13+
14+ /* verified links */
15+ xs *links_file = xs_fmt("%s/links.json", user->basedir);
16+
17+ if ((f = fopen(links_file, "r")) != NULL) {
18+ user->links = xs_json_load(f);
19+ fclose(f);
20+ }
21 }
22 else
23 srv_debug(1, xs_fmt("invalid user '%s'", uid));
M
html.c
+1,
-1
1@@ -767,7 +767,7 @@ static xs_html *html_user_body(snac *user, int local)
2 xs_str *k;
3 xs_str *v;
4
5- xs_dict *val_links = xs_dict_get(user->config, "validated_links");
6+ xs_dict *val_links = user->links;
7 if (xs_is_null(val_links))
8 val_links = xs_stock_dict;
9
+6,
-7
1@@ -624,15 +624,12 @@ xs_dict *mastoapi_account(const xs_dict *actor)
2
3 /* dict of validated links */
4 xs_dict *val_links = NULL;
5+ snac user = {0};
6
7 if (xs_startswith(id, srv_baseurl)) {
8 /* if it's a local user, open it and pick its validated links */
9- snac user;
10-
11- if (user_open(&user, prefu)) {
12- val_links = xs_dict_get(user.config, "validated_links");
13- user_free(&user);
14- }
15+ if (user_open(&user, prefu))
16+ val_links = user.links;
17 }
18
19 if (xs_is_null(val_links))
20@@ -662,6 +659,8 @@ xs_dict *mastoapi_account(const xs_dict *actor)
21 }
22 }
23
24+ user_free(&user);
25+
26 acct = xs_dict_append(acct, "fields", fields);
27
28 return acct;
29@@ -1157,7 +1156,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
30 xs_str *k;
31 xs_str *v;
32
33- xs_dict *val_links = xs_dict_get(snac1.config, "validated_links");
34+ xs_dict *val_links = snac1.links;
35 if (xs_is_null(val_links))
36 val_links = xs_stock_dict;
37
M
snac.h
+1,
-0
1@@ -41,6 +41,7 @@ typedef struct {
2 xs_dict *config; /* user configuration */
3 xs_dict *config_o; /* user configuration admin override */
4 xs_dict *key; /* keypair */
5+ xs_dict *links; /* validated links */
6 xs_str *actor; /* actor url */
7 xs_str *md5; /* actor url md5 */
8 } snac;