summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2024-02-15 17:34:46 +0100
committerGravatar default2024-02-15 17:34:46 +0100
commit263e239653b79d230a7546b9db89ff71dc0f2a53 (patch)
tree7d3718fe8a7927f4ea34028e2280ae384a05142b
parentmastoapi: fill the verified_at fields in mastoapi_account() for local users. (diff)
downloadsnac2-263e239653b79d230a7546b9db89ff71dc0f2a53.tar.gz
snac2-263e239653b79d230a7546b9db89ff71dc0f2a53.tar.xz
snac2-263e239653b79d230a7546b9db89ff71dc0f2a53.zip
Moved verified links to its own json file.
-rw-r--r--data.c9
-rw-r--r--html.c2
-rw-r--r--mastoapi.c13
-rw-r--r--snac.h1
4 files changed, 17 insertions, 8 deletions
diff --git a/data.c b/data.c
index 763eca3..e35a5dd 100644
--- a/data.c
+++ b/data.c
@@ -146,6 +146,7 @@ void user_free(snac *snac)
146 xs_free(snac->config); 146 xs_free(snac->config);
147 xs_free(snac->config_o); 147 xs_free(snac->config_o);
148 xs_free(snac->key); 148 xs_free(snac->key);
149 xs_free(snac->links);
149 xs_free(snac->actor); 150 xs_free(snac->actor);
150 xs_free(snac->md5); 151 xs_free(snac->md5);
151} 152}
@@ -233,6 +234,14 @@ int user_open(snac *user, const char *uid)
233 } 234 }
234 else 235 else
235 srv_debug(2, xs_fmt("error opening '%s' %d", cfg_file, errno)); 236 srv_debug(2, xs_fmt("error opening '%s' %d", cfg_file, errno));
237
238 /* verified links */
239 xs *links_file = xs_fmt("%s/links.json", user->basedir);
240
241 if ((f = fopen(links_file, "r")) != NULL) {
242 user->links = xs_json_load(f);
243 fclose(f);
244 }
236 } 245 }
237 else 246 else
238 srv_debug(1, xs_fmt("invalid user '%s'", uid)); 247 srv_debug(1, xs_fmt("invalid user '%s'", uid));
diff --git a/html.c b/html.c
index f95cb4f..4eb9b6a 100644
--- a/html.c
+++ b/html.c
@@ -767,7 +767,7 @@ static xs_html *html_user_body(snac *user, int local)
767 xs_str *k; 767 xs_str *k;
768 xs_str *v; 768 xs_str *v;
769 769
770 xs_dict *val_links = xs_dict_get(user->config, "validated_links"); 770 xs_dict *val_links = user->links;
771 if (xs_is_null(val_links)) 771 if (xs_is_null(val_links))
772 val_links = xs_stock_dict; 772 val_links = xs_stock_dict;
773 773
diff --git a/mastoapi.c b/mastoapi.c
index 4b7122c..8dcd6b4 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -624,15 +624,12 @@ xs_dict *mastoapi_account(const xs_dict *actor)
624 624
625 /* dict of validated links */ 625 /* dict of validated links */
626 xs_dict *val_links = NULL; 626 xs_dict *val_links = NULL;
627 snac user = {0};
627 628
628 if (xs_startswith(id, srv_baseurl)) { 629 if (xs_startswith(id, srv_baseurl)) {
629 /* if it's a local user, open it and pick its validated links */ 630 /* if it's a local user, open it and pick its validated links */
630 snac user; 631 if (user_open(&user, prefu))
631 632 val_links = user.links;
632 if (user_open(&user, prefu)) {
633 val_links = xs_dict_get(user.config, "validated_links");
634 user_free(&user);
635 }
636 } 633 }
637 634
638 if (xs_is_null(val_links)) 635 if (xs_is_null(val_links))
@@ -662,6 +659,8 @@ xs_dict *mastoapi_account(const xs_dict *actor)
662 } 659 }
663 } 660 }
664 661
662 user_free(&user);
663
665 acct = xs_dict_append(acct, "fields", fields); 664 acct = xs_dict_append(acct, "fields", fields);
666 665
667 return acct; 666 return acct;
@@ -1157,7 +1156,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
1157 xs_str *k; 1156 xs_str *k;
1158 xs_str *v; 1157 xs_str *v;
1159 1158
1160 xs_dict *val_links = xs_dict_get(snac1.config, "validated_links"); 1159 xs_dict *val_links = snac1.links;
1161 if (xs_is_null(val_links)) 1160 if (xs_is_null(val_links))
1162 val_links = xs_stock_dict; 1161 val_links = xs_stock_dict;
1163 1162
diff --git a/snac.h b/snac.h
index 0e4c6cd..7c3092b 100644
--- a/snac.h
+++ b/snac.h
@@ -41,6 +41,7 @@ typedef struct {
41 xs_dict *config; /* user configuration */ 41 xs_dict *config; /* user configuration */
42 xs_dict *config_o; /* user configuration admin override */ 42 xs_dict *config_o; /* user configuration admin override */
43 xs_dict *key; /* keypair */ 43 xs_dict *key; /* keypair */
44 xs_dict *links; /* validated links */
44 xs_str *actor; /* actor url */ 45 xs_str *actor; /* actor url */
45 xs_str *md5; /* actor url md5 */ 46 xs_str *md5; /* actor url md5 */
46} snac; 47} snac;