diff options
| -rw-r--r-- | data.c | 7 | ||||
| -rw-r--r-- | html.c | 33 | ||||
| -rw-r--r-- | snac.h | 1 |
3 files changed, 35 insertions, 6 deletions
| @@ -885,6 +885,13 @@ d_char *history_get(snac *snac, char *id) | |||
| 885 | } | 885 | } |
| 886 | 886 | ||
| 887 | 887 | ||
| 888 | int history_del(snac *snac, char *id) | ||
| 889 | { | ||
| 890 | xs *fn = _history_fn(snac, id); | ||
| 891 | return unlink(fn); | ||
| 892 | } | ||
| 893 | |||
| 894 | |||
| 888 | void enqueue_input(snac *snac, char *msg, char *req, int retries) | 895 | void enqueue_input(snac *snac, char *msg, char *req, int retries) |
| 889 | /* enqueues an input message */ | 896 | /* enqueues an input message */ |
| 890 | { | 897 | { |
| @@ -505,6 +505,10 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i | |||
| 505 | if ((actor = xs_dict_get(msg, "attributedTo")) == NULL) | 505 | if ((actor = xs_dict_get(msg, "attributedTo")) == NULL) |
| 506 | return os; | 506 | return os; |
| 507 | 507 | ||
| 508 | /* ignore muted morons immediately */ | ||
| 509 | if (is_muted(snac, actor)) | ||
| 510 | return os; | ||
| 511 | |||
| 508 | if (!valid_status(actor_get(snac, actor, &actor_o))) | 512 | if (!valid_status(actor_get(snac, actor, &actor_o))) |
| 509 | return os; | 513 | return os; |
| 510 | 514 | ||
| @@ -842,23 +846,40 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, | |||
| 842 | if (action == NULL) | 846 | if (action == NULL) |
| 843 | return 404; | 847 | return 404; |
| 844 | 848 | ||
| 845 | if (strcmp(action, "Like") == 0) { | 849 | snac_debug(&snac, 1, xs_fmt("web action '%s' received", action)); |
| 850 | |||
| 851 | status = 303; | ||
| 852 | |||
| 853 | if (strcmp(action, L("Like")) == 0) { | ||
| 846 | xs *msg = msg_admiration(&snac, id, "Like"); | 854 | xs *msg = msg_admiration(&snac, id, "Like"); |
| 847 | post(&snac, msg); | 855 | post(&snac, msg); |
| 848 | timeline_admire(&snac, id, snac.actor, 1); | 856 | timeline_admire(&snac, id, snac.actor, 1); |
| 849 | |||
| 850 | status = 303; | ||
| 851 | } | 857 | } |
| 852 | else | 858 | else |
| 853 | if (strcmp(action, "Boost") == 0) { | 859 | if (strcmp(action, L("Boost")) == 0) { |
| 854 | xs *msg = msg_admiration(&snac, id, "Announce"); | 860 | xs *msg = msg_admiration(&snac, id, "Announce"); |
| 855 | post(&snac, msg); | 861 | post(&snac, msg); |
| 856 | timeline_admire(&snac, id, snac.actor, 0); | 862 | timeline_admire(&snac, id, snac.actor, 0); |
| 857 | 863 | } | |
| 858 | status = 303; | 864 | else |
| 865 | if (strcmp(action, L("MUTE")) == 0) { | ||
| 866 | mute(&snac, actor); | ||
| 867 | } | ||
| 868 | else | ||
| 869 | if (strcmp(action, L("Follow")) == 0) { | ||
| 870 | } | ||
| 871 | else | ||
| 872 | if (strcmp(action, L("Unfollow")) == 0) { | ||
| 873 | } | ||
| 874 | else | ||
| 875 | if (strcmp(action, L("Delete")) == 0) { | ||
| 859 | } | 876 | } |
| 860 | else | 877 | else |
| 861 | status = 404; | 878 | status = 404; |
| 879 | |||
| 880 | /* delete the cached timeline */ | ||
| 881 | if (status == 303) | ||
| 882 | history_del(&snac, "_timeline.html"); | ||
| 862 | } | 883 | } |
| 863 | else | 884 | else |
| 864 | if (p_path && strcmp(p_path, "admin/user-setup") == 0) { | 885 | if (p_path && strcmp(p_path, "admin/user-setup") == 0) { |
| @@ -88,6 +88,7 @@ int static_get(snac *snac, char *id, d_char **data, int *size); | |||
| 88 | double history_mtime(snac *snac, char *id); | 88 | double history_mtime(snac *snac, char *id); |
| 89 | void history_add(snac *snac, char *id, char *content, int size); | 89 | void history_add(snac *snac, char *id, char *content, int size); |
| 90 | d_char *history_get(snac *snac, char *id); | 90 | d_char *history_get(snac *snac, char *id); |
| 91 | int history_del(snac *snac, char *id); | ||
| 91 | 92 | ||
| 92 | void enqueue_input(snac *snac, char *msg, char *req, int retries); | 93 | void enqueue_input(snac *snac, char *msg, char *req, int retries); |
| 93 | void enqueue_output(snac *snac, char *msg, char *actor, int retries); | 94 | void enqueue_output(snac *snac, char *msg, char *actor, int retries); |