mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-12-24 00:23:38 +00:00
New file ~user/user_o.json, for the admin to override user settings.
This commit is contained in:
parent
dca071b14d
commit
0f4db7cf26
2 changed files with 24 additions and 7 deletions
16
data.c
16
data.c
|
@ -130,6 +130,7 @@ void user_free(snac *snac)
|
|||
xs_free(snac->uid);
|
||||
xs_free(snac->basedir);
|
||||
xs_free(snac->config);
|
||||
xs_free(snac->config_o);
|
||||
xs_free(snac->key);
|
||||
xs_free(snac->actor);
|
||||
xs_free(snac->md5);
|
||||
|
@ -172,7 +173,22 @@ int user_open(snac *snac, const char *uid)
|
|||
if ((snac->key = xs_json_loads(key_data)) != NULL) {
|
||||
snac->actor = xs_fmt("%s/%s", srv_baseurl, uid);
|
||||
snac->md5 = xs_md5_hex(snac->actor, strlen(snac->actor));
|
||||
|
||||
/* everything is ok right now */
|
||||
ret = 1;
|
||||
|
||||
/* does it have a configuration override? */
|
||||
xs *cfg_file_o = xs_fmt("%s/user_o.json", snac->basedir);
|
||||
if ((f = fopen(cfg_file_o, "r")) != NULL) {
|
||||
xs *j = xs_readall(f);
|
||||
fclose(f);
|
||||
|
||||
if ((snac->config_o = xs_json_loads(j)) == NULL)
|
||||
srv_log(xs_fmt("cannot parse '%s'", cfg_file_o));
|
||||
}
|
||||
|
||||
if (snac->config_o == NULL)
|
||||
snac->config_o = xs_dict_new();
|
||||
}
|
||||
else
|
||||
srv_log(xs_fmt("cannot parse '%s'", key_file));
|
||||
|
|
15
snac.h
15
snac.h
|
@ -1,7 +1,7 @@
|
|||
/* snac - A simple, minimalistic ActivityPub instance */
|
||||
/* copyright (c) 2022 - 2023 grunfink / MIT license */
|
||||
|
||||
#define VERSION "2.22"
|
||||
#define VERSION "2.23-dev"
|
||||
|
||||
#define USER_AGENT "snac/" VERSION
|
||||
|
||||
|
@ -30,12 +30,13 @@ int srv_open(char *basedir, int auto_upgrade);
|
|||
void srv_free(void);
|
||||
|
||||
typedef struct _snac {
|
||||
d_char *uid; /* uid */
|
||||
d_char *basedir; /* user base directory */
|
||||
d_char *config; /* user configuration */
|
||||
d_char *key; /* keypair */
|
||||
d_char *actor; /* actor url */
|
||||
d_char *md5; /* actor url md5 */
|
||||
xs_str *uid; /* uid */
|
||||
xs_str *basedir; /* user base directory */
|
||||
xs_dict *config; /* user configuration */
|
||||
xs_dict *config_o; /* user configuration admin override */
|
||||
xs_dict *key; /* keypair */
|
||||
xs_str *actor; /* actor url */
|
||||
xs_str *md5; /* actor url md5 */
|
||||
} snac;
|
||||
|
||||
int user_open(snac *snac, const char *uid);
|
||||
|
|
Loading…
Reference in a new issue