commit 0db1cf0
default
·
2024-11-24 08:14:59 +0000 UTC
parent 0ddbe7e
New web actions "Approve" and "Discard".
M
html.c
+28,
-0
1@@ -3699,6 +3699,34 @@ int html_post_handler(const xs_dict *req, const char *q_path,
2 unbookmark(&snac, id);
3 timeline_touch(&snac);
4 }
5+ else
6+ if (strcmp(action, L("Approve")) == 0) { /** **/
7+ xs *fwreq = pending_get(&snac, actor);
8+
9+ if (fwreq != NULL) {
10+ xs *reply = msg_accept(&snac, fwreq, actor);
11+
12+ enqueue_message(&snac, reply);
13+
14+ if (xs_is_null(xs_dict_get(fwreq, "published"))) {
15+ /* add a date if it doesn't include one (Mastodon) */
16+ xs *date = xs_str_utctime(0, ISO_DATE_SPEC);
17+ fwreq = xs_dict_set(fwreq, "published", date);
18+ }
19+
20+ timeline_add(&snac, xs_dict_get(fwreq, "id"), fwreq);
21+
22+ follower_add(&snac, actor);
23+
24+ pending_del(&snac, actor);
25+
26+ snac_log(&snac, xs_fmt("new follower %s", actor));
27+ }
28+ }
29+ else
30+ if (strcmp(action, L("Discard")) == 0) { /** **/
31+ pending_del(&snac, actor);
32+ }
33 else
34 status = HTTP_STATUS_NOT_FOUND;
35
M
snac.h
+1,
-0
1@@ -320,6 +320,7 @@ xs_dict *msg_update(snac *snac, const xs_dict *object);
2 xs_dict *msg_ping(snac *user, const char *rcpt);
3 xs_dict *msg_pong(snac *user, const char *rcpt, const char *object);
4 xs_dict *msg_move(snac *user, const char *new_account);
5+xs_dict *msg_accept(snac *snac, const xs_val *object, const char *to);
6 xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
7 const xs_list *opts, int multiple, int end_secs);
8