Mute and block pages

FossilOrigin-Name: 0fa2aeb7c66595fade365d8c4ea7d027b83657aa9679223b13ee6844f7b7ae32
This commit is contained in:
nekobit 2022-06-12 05:44:45 +00:00
parent d3bf48a1ed
commit 8d153983d6
5 changed files with 82 additions and 10 deletions

View file

@ -40,6 +40,7 @@
#include "../static/account_stub.ctmpl"
#include "../static/account_sidebar.ctmpl"
#include "../static/account_current_menubar.ctmpl"
#include "../static/basic_page.ctmpl"
#define FOLLOWS_YOU_HTML "<span class=\"acct-badge\">%s</span>"
@ -174,7 +175,6 @@ static char* account_following_cb(struct session* ssn,
NULL);
}
easprintf(&output, "%s%s",
STR_NULL_EMPTY(navigation_box),
STR_NULL_EMPTY(accounts_html),
STR_NULL_EMPTY(navigation_box));
@ -684,9 +684,81 @@ void content_account_bookmarks(struct session* ssn, mastodont_t* api, char** dat
// Cleanup
mastodont_storage_cleanup(&storage);
mstdnt_cleanup_statuses(statuses, status_count);
if (status_format) free(status_format);
if (navigation_box) free(navigation_box);
if (output) free(output);
free(status_format);
free(navigation_box);
free(output);
}
static void accounts_page(mastodont_t* api,
struct session* ssn,
struct mstdnt_storage* storage,
char* header,
struct mstdnt_account* accts,
size_t accts_len)
{
char* output;
char* content = construct_accounts(api, accts, accts_len, 0, NULL);
if (!content)
content = construct_error("No accounts here!", E_NOTICE, 1, NULL);
struct basic_page_template tdata = {
.back_ref = getenv("HTTP_REFERER"),
.page_title = header,
.page_content = content,
};
output = tmpl_gen_basic_page(&tdata, NULL);
struct base_page b = {
.category = BASE_CAT_NONE,
.content = output,
.sidebar_left = NULL
};
// Output
render_base_page(&b, ssn, api);
mastodont_storage_cleanup(storage);
free(output);
free(content);
}
void content_account_blocked(struct session* ssn, mastodont_t* api, char** data)
{
struct mstdnt_account_args args = {
.max_id = keystr(ssn->post.max_id),
.since_id = NULL,
.min_id = keystr(ssn->post.min_id),
.offset = 0,
.limit = 20,
.with_relationships = 0,
};
struct mstdnt_storage storage = { 0 };
struct mstdnt_account* accts = NULL;
size_t accts_len = 0;
mastodont_get_blocks(api, &args, &storage, &accts, &accts_len);
accounts_page(api, ssn, &storage, "Blocked users", accts, accts_len);
}
void content_account_muted(struct session* ssn, mastodont_t* api, char** data)
{
struct mstdnt_account_args args = {
.max_id = keystr(ssn->post.max_id),
.since_id = NULL,
.min_id = keystr(ssn->post.min_id),
.offset = 0,
.limit = 20,
.with_relationships = 0,
};
struct mstdnt_storage storage = { 0 };
struct mstdnt_account* accts = NULL;
size_t accts_len = 0;
mastodont_get_mutes(api, &args, &storage, &accts, &accts_len);
accounts_page(api, ssn, &storage, "Muted users", accts, accts_len);
}
void content_account_favourites(struct session* ssn, mastodont_t* api, char** data)

View file

@ -88,6 +88,8 @@ void content_account_following(struct session* ssn, mastodont_t* api, char** dat
void content_account_statuses(struct session* ssn, mastodont_t* api, char** data);
void content_account_scrobbles(struct session* ssn, mastodont_t* api, char** data);
void content_account_pinned(struct session* ssn, mastodont_t* api, char** data);
void content_account_blocked(struct session* ssn, mastodont_t* api, char** data);
void content_account_muted(struct session* ssn, mastodont_t* api, char** data);
void content_account_media(struct session* ssn, mastodont_t* api, char** data);
void content_account_action(struct session* ssn, mastodont_t* api, char** data);
void content_account_favourites(struct session* ssn, mastodont_t* api, char** data);

View file

@ -97,6 +97,8 @@ int main(void)
{ "/local", content_tl_local },
{ "/bookmarks", content_account_bookmarks },
{ "/favourites", content_account_favourites },
{ "/blocked", content_account_blocked },
{ "/muted", content_account_muted },
{ "/notifications_compact", content_notifications_compact },
{ "/notifications", content_notifications },
{ "/tag/:", content_tl_tag },

View file

@ -1,4 +1,4 @@
<div class="simple-page">
<h1><a href="{{ %s : back_ref }}" class="page-back-btn">&lt;</a> {{ %s : blocks_str }}</h1>
<h1><a href="{{ %s : back_ref }}" class="page-back-btn">&lt;</a> {{ %s : page_title }}</h1>
</div>
{{%s : blocks}}
{{%s : page_content}}

View file

@ -1,4 +0,0 @@
<div class="simple-page">
<h1><a href="{{ %s : back_ref }}" class="page-back-btn">&lt;</a> {{ %s : mutes_str }}</h1>
</div>
{{%s : mutes}}