Fix load config issue
FossilOrigin-Name: 7157e585f85b26cea9225c4db43a934c51f10cbe0a3342464911fcf09c277a90
This commit is contained in:
parent
917563c264
commit
20f7b66142
4 changed files with 35 additions and 12 deletions
|
@ -43,17 +43,7 @@ void render_base_page(struct base_page* page, struct session* ssn, mastodont_t*
|
|||
struct mstdnt_notification* notifs = NULL;
|
||||
size_t notifs_len;
|
||||
|
||||
if (!ssn->config.changed && cookie)
|
||||
{
|
||||
if (ssn->cookies.theme)
|
||||
ssn->config.theme = ssn->cookies.theme;
|
||||
if (ssn->cookies.logged_in)
|
||||
login_string = "";
|
||||
if (ssn->cookies.themeclr)
|
||||
ssn->config.themeclr = ssn->cookies.themeclr;
|
||||
if (ssn->cookies.background_url)
|
||||
ssn->config.background_url = ssn->cookies.background_url;
|
||||
}
|
||||
read_config(ssn);
|
||||
|
||||
if (ssn->config.background_url)
|
||||
{
|
||||
|
|
|
@ -56,6 +56,9 @@ char* read_cookies_env(struct cookie_values* cookies)
|
|||
{ "instance_url", &(cookies->instance_url), key_string },
|
||||
{ "background_url", &(cookies->background_url), key_string },
|
||||
{ "themeclr", &(cookies->themeclr), key_int },
|
||||
{ "jsactions", &(cookies->jsactions), key_int },
|
||||
{ "jsreply", &(cookies->jsreply), key_int },
|
||||
{ "jslive", &(cookies->jslive), key_int },
|
||||
};
|
||||
|
||||
do
|
||||
|
|
|
@ -28,6 +28,9 @@ struct cookie_values
|
|||
char* instance_url;
|
||||
char* background_url;
|
||||
int themeclr;
|
||||
int jsactions;
|
||||
int jsreply;
|
||||
int jslive;
|
||||
};
|
||||
|
||||
struct http_cookie_info
|
||||
|
|
|
@ -51,7 +51,7 @@ int set_config_int(int* ssn,
|
|||
if (ssn)
|
||||
{
|
||||
*ssn = str_l;
|
||||
printf("Set-Cookie: %s=%ld; HttpOnly; Path=/; SameSite=Strict;\r\n",
|
||||
printf("Set-Cookie: %s=%ld; HttpOnly; Path=/; Max-Age=31536000; SameSite=Strict;\r\n",
|
||||
cookie_name, str_l);
|
||||
}
|
||||
|
||||
|
@ -79,3 +79,30 @@ void load_config(struct session* ssn, mastodont_t* api)
|
|||
set_config_int(&(ssn->config.jsreply), "jsreply", ssn->post.jsreply);
|
||||
set_config_int(&(ssn->config.jslive), "jslive", ssn->post.jslive);
|
||||
}
|
||||
|
||||
#define SET_COOKIE_CONFIG(post, cookie, config) do{ \
|
||||
if (cookie && !post) \
|
||||
config = cookie; \
|
||||
} while(0);
|
||||
|
||||
void read_config(struct session* ssn)
|
||||
{
|
||||
SET_COOKIE_CONFIG(ssn->post.theme,
|
||||
ssn->cookies.theme,
|
||||
ssn->config.theme);
|
||||
SET_COOKIE_CONFIG(ssn->post.themeclr,
|
||||
ssn->cookies.themeclr,
|
||||
ssn->config.themeclr);
|
||||
SET_COOKIE_CONFIG(ssn->post.jsactions,
|
||||
ssn->cookies.jsactions,
|
||||
ssn->config.jsactions);
|
||||
SET_COOKIE_CONFIG(ssn->post.jsreply,
|
||||
ssn->cookies.jsreply,
|
||||
ssn->config.jsreply);
|
||||
SET_COOKIE_CONFIG(ssn->post.jslive,
|
||||
ssn->cookies.jslive,
|
||||
ssn->config.jslive);
|
||||
SET_COOKIE_CONFIG((ssn->post.files.content && ssn->post.files.content[0].content),
|
||||
ssn->cookies.background_url,
|
||||
ssn->config.background_url);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue