refactor(lsm): decouple attribute types

This commit is contained in:
Jef Roosens 2023-11-08 12:25:47 +01:00
parent 535b92a6b6
commit b5fc3a3612
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
6 changed files with 26 additions and 32 deletions

View file

@ -80,14 +80,14 @@ bool lander_get_entry_lsm(event_loop_conn *conn) {
lander_entry_type t;
lsm_entry_attr_get_num((uint64_t *)&t, c_ctx->entry,
lsm_attr_type_entry_type);
lander_attr_type_entry_type);
if (t == lander_entry_type_redirect) {
// For redirects, the URL is stored as an in-memory attribute
lsm_str *url_attr_val;
// This shouldn't be able to happen
if (lsm_entry_attr_get(&url_attr_val, c_ctx->entry, lsm_attr_type_url) !=
if (lsm_entry_attr_get(&url_attr_val, c_ctx->entry, lander_attr_type_url) !=
lsm_error_ok) {
error("Entry of type redirect detected without URL attribute");

View file

@ -132,7 +132,7 @@ bool lander_post_redirect_lsm(event_loop_conn *conn) {
return true;
}
lsm_entry_attr_insert_num(c_ctx->entry, lsm_attr_type_entry_type,
lsm_entry_attr_insert_num(c_ctx->entry, lander_attr_type_entry_type,
lander_entry_type_redirect);
return true;
@ -144,7 +144,7 @@ bool lander_post_redirect_body_to_attr(event_loop_conn *conn) {
lsm_str *attr_value;
lsm_str_init_copy_n(&attr_value, ctx->req.body.buf, ctx->req.body.len);
lsm_entry_attr_insert(c_ctx->entry, lsm_attr_type_url, attr_value);
lsm_entry_attr_insert(c_ctx->entry, lander_attr_type_url, attr_value);
return true;
}
@ -171,7 +171,7 @@ bool lander_post_paste_lsm(event_loop_conn *conn) {
return true;
}
lsm_entry_attr_insert_num(c_ctx->entry, lsm_attr_type_entry_type,
lsm_entry_attr_insert_num(c_ctx->entry, lander_attr_type_entry_type,
lander_entry_type_paste);
return true;