diff --git a/src/lists.c b/src/lists.c index c56d857..715e5d7 100644 --- a/src/lists.c +++ b/src/lists.c @@ -25,7 +25,7 @@ #include "status.h" #include "lists.h" #include "string_helpers.h" - +#include "http.h" // Files #include "../static/account.ctmpl" #include "../static/list.ctmpl" @@ -105,3 +105,23 @@ void content_lists(struct session* ssn, mastodont_t* api, char** data) if (lists_page) free(lists_page); mstdnt_cleanup_lists(lists); } + +void list_edit(struct session* ssn, mastodont_t* api, char** data) +{ + struct mstdnt_storage storage = { 0 }; + char* referer = getenv("HTTP_REFERER"); + char* id = data[0]; + + struct mstdnt_list_args args = { + .title = keystr(ssn->post.title), + .replies_policy = keyint(ssn->post.replies_policy) + }; + + mastodont_update_list(api, + id, + &args, + &storage, + NULL); + + redirect(REDIRECT_303, referer); +} diff --git a/src/lists.h b/src/lists.h index 7c40eb5..a90e5c3 100644 --- a/src/lists.h +++ b/src/lists.h @@ -26,5 +26,6 @@ char* construct_list(struct mstdnt_list* list, size_t* size); char* construct_lists(struct mstdnt_list* lists, size_t size, size_t* ret_size); char* construct_lists_view(char* lists_string, size_t* size); void content_lists(struct session* ssn, mastodont_t* api, char** data); +void list_edit(struct session* ssn, mastodont_t* api, char** data); #endif // LISTS_H diff --git a/src/main.c b/src/main.c index 16fe7b7..1f083b6 100644 --- a/src/main.c +++ b/src/main.c @@ -90,6 +90,7 @@ int main(void) { "/search/accounts", content_search_accounts }, { "/search/hashtags", content_search_hashtags }, { "/search", content_search_all }, + { "/lists/edit/:", list_edit }, { "/lists/for/:", content_tl_list }, { "/lists", content_lists }, { "/federated", content_tl_federated }, diff --git a/src/query.c b/src/query.c index ee7986a..a8d32fb 100644 --- a/src/query.c +++ b/src/query.c @@ -91,6 +91,7 @@ char* read_post_data(struct post_values* post) { "itype", &(post->itype), key_string }, { "id", &(post->id), key_string }, { "title", &(post->title), key_string }, + { "replies_policy", &(post->replies_policy), key_int }, { "theme", &(post->theme), key_string }, { "themeclr", &(post->themeclr), key_int }, { "jsactions", &(post->jsactions), key_int }, diff --git a/src/query.h b/src/query.h index 8307e57..bb706de 100644 --- a/src/query.h +++ b/src/query.h @@ -51,6 +51,7 @@ struct post_values struct key set; // Int struct key only_media; // Int struct key replies_only; // Int + struct key replies_policy; // Int struct key content; // String struct key itype; // String diff --git a/static/list.tmpl b/static/list.tmpl index ce2d564..85f9270 100644 --- a/static/list.tmpl +++ b/static/list.tmpl @@ -3,7 +3,7 @@
-
+