Lists update

FossilOrigin-Name: 44a4c4611a6af7048dcaa15d6a2d576373a39af9d77312481908a53add3bb761
This commit is contained in:
nekobit 2022-06-22 05:27:51 +00:00
parent c88c30996c
commit 8432e66cb4
6 changed files with 26 additions and 2 deletions

View file

@ -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);
}

View file

@ -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

View file

@ -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 },

View file

@ -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 },

View file

@ -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

View file

@ -3,7 +3,7 @@
<input type="checkbox" id="list-edit-{{%s:list_id}}" class="list-radio-show hidden" name="list-radio" class="hidden">
<div class="list-edit-content">
<form action="{{%s:prefix}}/lists/edit/{{%s:list_id}}">
<form action="{{%s:prefix}}/lists/edit/{{%s:list_id}}" method="post">
<input type="text" name="title">
<select name="replies_policy">
<option value="0">None</option>