New MUTE web action.

This commit is contained in:
default 2022-10-01 07:45:36 +02:00
parent 8e27f1d711
commit 3797355f94
3 changed files with 35 additions and 6 deletions

7
data.c
View file

@ -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) void enqueue_input(snac *snac, char *msg, char *req, int retries)
/* enqueues an input message */ /* enqueues an input message */
{ {

33
html.c
View file

@ -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) if ((actor = xs_dict_get(msg, "attributedTo")) == NULL)
return os; return os;
/* ignore muted morons immediately */
if (is_muted(snac, actor))
return os;
if (!valid_status(actor_get(snac, actor, &actor_o))) if (!valid_status(actor_get(snac, actor, &actor_o)))
return os; 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) if (action == NULL)
return 404; 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"); xs *msg = msg_admiration(&snac, id, "Like");
post(&snac, msg); post(&snac, msg);
timeline_admire(&snac, id, snac.actor, 1); timeline_admire(&snac, id, snac.actor, 1);
status = 303;
} }
else else
if (strcmp(action, "Boost") == 0) { if (strcmp(action, L("Boost")) == 0) {
xs *msg = msg_admiration(&snac, id, "Announce"); xs *msg = msg_admiration(&snac, id, "Announce");
post(&snac, msg); post(&snac, msg);
timeline_admire(&snac, id, snac.actor, 0); 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 else
status = 404; status = 404;
/* delete the cached timeline */
if (status == 303)
history_del(&snac, "_timeline.html");
} }
else else
if (p_path && strcmp(p_path, "admin/user-setup") == 0) { if (p_path && strcmp(p_path, "admin/user-setup") == 0) {

1
snac.h
View file

@ -88,6 +88,7 @@ int static_get(snac *snac, char *id, d_char **data, int *size);
double history_mtime(snac *snac, char *id); double history_mtime(snac *snac, char *id);
void history_add(snac *snac, char *id, char *content, int size); void history_add(snac *snac, char *id, char *content, int size);
d_char *history_get(snac *snac, char *id); 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_input(snac *snac, char *msg, char *req, int retries);
void enqueue_output(snac *snac, char *msg, char *actor, int retries); void enqueue_output(snac *snac, char *msg, char *actor, int retries);