mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 09:35:04 +00:00
Moved verified links to its own json file.
This commit is contained in:
parent
2afcb4b6ec
commit
263e239653
4 changed files with 17 additions and 8 deletions
9
data.c
9
data.c
|
@ -146,6 +146,7 @@ void user_free(snac *snac)
|
|||
xs_free(snac->config);
|
||||
xs_free(snac->config_o);
|
||||
xs_free(snac->key);
|
||||
xs_free(snac->links);
|
||||
xs_free(snac->actor);
|
||||
xs_free(snac->md5);
|
||||
}
|
||||
|
@ -233,6 +234,14 @@ int user_open(snac *user, const char *uid)
|
|||
}
|
||||
else
|
||||
srv_debug(2, xs_fmt("error opening '%s' %d", cfg_file, errno));
|
||||
|
||||
/* verified links */
|
||||
xs *links_file = xs_fmt("%s/links.json", user->basedir);
|
||||
|
||||
if ((f = fopen(links_file, "r")) != NULL) {
|
||||
user->links = xs_json_load(f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
else
|
||||
srv_debug(1, xs_fmt("invalid user '%s'", uid));
|
||||
|
|
2
html.c
2
html.c
|
@ -767,7 +767,7 @@ static xs_html *html_user_body(snac *user, int local)
|
|||
xs_str *k;
|
||||
xs_str *v;
|
||||
|
||||
xs_dict *val_links = xs_dict_get(user->config, "validated_links");
|
||||
xs_dict *val_links = user->links;
|
||||
if (xs_is_null(val_links))
|
||||
val_links = xs_stock_dict;
|
||||
|
||||
|
|
13
mastoapi.c
13
mastoapi.c
|
@ -624,15 +624,12 @@ xs_dict *mastoapi_account(const xs_dict *actor)
|
|||
|
||||
/* dict of validated links */
|
||||
xs_dict *val_links = NULL;
|
||||
snac user = {0};
|
||||
|
||||
if (xs_startswith(id, srv_baseurl)) {
|
||||
/* if it's a local user, open it and pick its validated links */
|
||||
snac user;
|
||||
|
||||
if (user_open(&user, prefu)) {
|
||||
val_links = xs_dict_get(user.config, "validated_links");
|
||||
user_free(&user);
|
||||
}
|
||||
if (user_open(&user, prefu))
|
||||
val_links = user.links;
|
||||
}
|
||||
|
||||
if (xs_is_null(val_links))
|
||||
|
@ -662,6 +659,8 @@ xs_dict *mastoapi_account(const xs_dict *actor)
|
|||
}
|
||||
}
|
||||
|
||||
user_free(&user);
|
||||
|
||||
acct = xs_dict_append(acct, "fields", fields);
|
||||
|
||||
return acct;
|
||||
|
@ -1157,7 +1156,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
|
|||
xs_str *k;
|
||||
xs_str *v;
|
||||
|
||||
xs_dict *val_links = xs_dict_get(snac1.config, "validated_links");
|
||||
xs_dict *val_links = snac1.links;
|
||||
if (xs_is_null(val_links))
|
||||
val_links = xs_stock_dict;
|
||||
|
||||
|
|
1
snac.h
1
snac.h
|
@ -41,6 +41,7 @@ typedef struct {
|
|||
xs_dict *config; /* user configuration */
|
||||
xs_dict *config_o; /* user configuration admin override */
|
||||
xs_dict *key; /* keypair */
|
||||
xs_dict *links; /* validated links */
|
||||
xs_str *actor; /* actor url */
|
||||
xs_str *md5; /* actor url md5 */
|
||||
} snac;
|
||||
|
|
Loading…
Reference in a new issue