mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-27 07:13:36 +00:00
The people page shows 'Approve' and 'Discard' buttons for pending follows.
This commit is contained in:
parent
96576d2c5d
commit
9fb84bcb3a
2 changed files with 38 additions and 11 deletions
20
data.c
20
data.c
|
@ -1270,12 +1270,22 @@ xs_list *pending_list(snac *user)
|
|||
const char *v;
|
||||
|
||||
xs_list_foreach(l, v) {
|
||||
const char *actor = xs_dict_get(v, "actor");
|
||||
FILE *f;
|
||||
xs *msg = NULL;
|
||||
|
||||
if (xs_type(actor) == XSTYPE_STRING) {
|
||||
xs *md5 = xs_md5_hex(actor, strlen(actor));
|
||||
r = xs_list_append(r, md5);
|
||||
}
|
||||
if ((f = fopen(v, "r")) == NULL)
|
||||
continue;
|
||||
|
||||
msg = xs_json_load(f);
|
||||
fclose(f);
|
||||
|
||||
if (msg == NULL)
|
||||
continue;
|
||||
|
||||
const char *actor = xs_dict_get(msg, "actor");
|
||||
|
||||
if (xs_type(actor) == XSTYPE_STRING)
|
||||
r = xs_list_append(r, actor);
|
||||
}
|
||||
|
||||
return r;
|
||||
|
|
29
html.c
29
html.c
|
@ -2470,10 +2470,9 @@ xs_html *html_people_list(snac *snac, xs_list *list, char *header, char *t, cons
|
|||
xs_html_tag("summary",
|
||||
xs_html_text("..."))));
|
||||
|
||||
xs_list *p = list;
|
||||
const char *actor_id;
|
||||
|
||||
while (xs_list_iter(&p, &actor_id)) {
|
||||
xs_list_foreach(list, actor_id) {
|
||||
xs *md5 = xs_md5_hex(actor_id, strlen(actor_id));
|
||||
xs *actor = NULL;
|
||||
|
||||
|
@ -2542,6 +2541,14 @@ xs_html *html_people_list(snac *snac, xs_list *list, char *header, char *t, cons
|
|||
html_button("limit", L("Limit"),
|
||||
L("Block announces (boosts) from this user")));
|
||||
}
|
||||
if (pending_check(snac, actor_id)) {
|
||||
xs_html_add(form,
|
||||
html_button("approve", L("Approve"),
|
||||
L("Approve this follow request")));
|
||||
|
||||
xs_html_add(form,
|
||||
html_button("discard", L("Discard"), L("Discard this follow request")));
|
||||
}
|
||||
else {
|
||||
xs_html_add(form,
|
||||
html_button("follow", L("Follow"),
|
||||
|
@ -2596,13 +2603,23 @@ xs_str *html_people(snac *user)
|
|||
xs *wing = following_list(user);
|
||||
xs *wers = follower_list(user);
|
||||
|
||||
xs_html *lists = xs_html_tag("div",
|
||||
xs_html_attr("class", "snac-posts"));
|
||||
|
||||
if (xs_is_true(xs_dict_get(user->config, "approve_followers"))) {
|
||||
xs *pending = pending_list(user);
|
||||
xs_html_add(lists,
|
||||
html_people_list(user, pending, L("Pending follow confirmations"), "p", proxy));
|
||||
}
|
||||
|
||||
xs_html_add(lists,
|
||||
html_people_list(user, wing, L("People you follow"), "i", proxy),
|
||||
html_people_list(user, wers, L("People that follow you"), "e", proxy));
|
||||
|
||||
xs_html *html = xs_html_tag("html",
|
||||
html_user_head(user, NULL, NULL),
|
||||
xs_html_add(html_user_body(user, 0),
|
||||
xs_html_tag("div",
|
||||
xs_html_attr("class", "snac-posts"),
|
||||
html_people_list(user, wing, L("People you follow"), "i", proxy),
|
||||
html_people_list(user, wers, L("People that follow you"), "e", proxy)),
|
||||
lists,
|
||||
html_footer()));
|
||||
|
||||
return xs_html_render_s(html, "<!DOCTYPE html>\n");
|
||||
|
|
Loading…
Reference in a new issue