diff --git a/data.c b/data.c index 4aba816..9051810 100644 --- a/data.c +++ b/data.c @@ -885,6 +885,13 @@ d_char *history_get(snac *snac, char *id) } +int history_del(snac *snac, char *id) +{ + xs *fn = _history_fn(snac, id); + return unlink(fn); +} + + void enqueue_input(snac *snac, char *msg, char *req, int retries) /* enqueues an input message */ { diff --git a/html.c b/html.c index 9687bed..f2f8b33 100644 --- a/html.c +++ b/html.c @@ -505,6 +505,10 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i if ((actor = xs_dict_get(msg, "attributedTo")) == NULL) return os; + /* ignore muted morons immediately */ + if (is_muted(snac, actor)) + return os; + if (!valid_status(actor_get(snac, actor, &actor_o))) return os; @@ -842,23 +846,40 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, if (action == NULL) return 404; - if (strcmp(action, "Like") == 0) { + snac_debug(&snac, 1, xs_fmt("web action '%s' received", action)); + + status = 303; + + if (strcmp(action, L("Like")) == 0) { xs *msg = msg_admiration(&snac, id, "Like"); post(&snac, msg); timeline_admire(&snac, id, snac.actor, 1); - - status = 303; } else - if (strcmp(action, "Boost") == 0) { + if (strcmp(action, L("Boost")) == 0) { xs *msg = msg_admiration(&snac, id, "Announce"); post(&snac, msg); timeline_admire(&snac, id, snac.actor, 0); - - status = 303; + } + else + if (strcmp(action, L("MUTE")) == 0) { + mute(&snac, actor); + } + else + if (strcmp(action, L("Follow")) == 0) { + } + else + if (strcmp(action, L("Unfollow")) == 0) { + } + else + if (strcmp(action, L("Delete")) == 0) { } else status = 404; + + /* delete the cached timeline */ + if (status == 303) + history_del(&snac, "_timeline.html"); } else if (p_path && strcmp(p_path, "admin/user-setup") == 0) { diff --git a/snac.h b/snac.h index 0dce10a..26f153e 100644 --- a/snac.h +++ b/snac.h @@ -88,6 +88,7 @@ int static_get(snac *snac, char *id, d_char **data, int *size); double history_mtime(snac *snac, char *id); void history_add(snac *snac, char *id, char *content, int size); d_char *history_get(snac *snac, char *id); +int history_del(snac *snac, char *id); void enqueue_input(snac *snac, char *msg, char *req, int retries); void enqueue_output(snac *snac, char *msg, char *actor, int retries);