default 3 лет назад
Родитель
Сommit
3797355f94
3 измененных файлов с 35 добавлено и 6 удалено
  1. 7 0
      data.c
  2. 27 6
      html.c
  3. 1 0
      snac.h

+ 7 - 0
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 */
 {

+ 27 - 6
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) {

+ 1 - 0
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);