Răsfoiți Sursa

Use snac_op in actor_failure().

default 3 săptămâni în urmă
părinte
comite
71a83e6578
4 a modificat fișierele cu 22 adăugiri și 11 ștergeri
  1. 5 5
      activitypub.c
  2. 7 4
      data.c
  3. 1 1
      html.c
  4. 9 1
      snac.h

+ 5 - 5
activitypub.c

@@ -3054,7 +3054,7 @@ int process_input_message(snac *snac, const xs_dict *msg, const xs_dict *req)
                         followed_hashtag_distribute(a_msg);
                         followed_hashtag_distribute(a_msg);
 
 
                         /* actor is [back] alive */
                         /* actor is [back] alive */
-                        actor_failure(who, 2);
+                        actor_failure(who, OP_DEL);
 
 
                         do_notify = 1;
                         do_notify = 1;
                     }
                     }
@@ -3461,7 +3461,7 @@ void process_user_queue_item(snac *user, xs_dict *q_item)
         const char *actor = xs_dict_get(q_item, "actor");
         const char *actor = xs_dict_get(q_item, "actor");
         double mtime = object_mtime(actor);
         double mtime = object_mtime(actor);
 
 
-        if (actor_failure(actor, 0) == -1) {
+        if (actor_failure(actor, OP_CHECK) == -1) {
             /* actor is broken beyond repair */
             /* actor is broken beyond repair */
             snac_debug(user, 1, xs_fmt("actor_refresh skipped broken actor %s", actor));
             snac_debug(user, 1, xs_fmt("actor_refresh skipped broken actor %s", actor));
         }
         }
@@ -3478,16 +3478,16 @@ void process_user_queue_item(snac *user, xs_dict *q_item)
                 actor_add(actor, actor_o);
                 actor_add(actor, actor_o);
 
 
                 /* mark actor and instance as working */
                 /* mark actor and instance as working */
-                actor_failure(actor, 2);
+                actor_failure(actor, OP_DEL);
                 instance_failure(actor, 2);
                 instance_failure(actor, 2);
             }
             }
             else {
             else {
                 if (status == HTTP_STATUS_GONE || status == HTTP_STATUS_NOT_FOUND) {
                 if (status == HTTP_STATUS_GONE || status == HTTP_STATUS_NOT_FOUND) {
-                    actor_failure(actor, 1);
+                    actor_failure(actor, OP_ADD);
                     snac_log(user, xs_fmt("actor_refresh marking actor %s as broken %d", actor, status));
                     snac_log(user, xs_fmt("actor_refresh marking actor %s as broken %d", actor, status));
                 }
                 }
                 else {
                 else {
-                    actor_failure(actor, 2);
+                    actor_failure(actor, OP_DEL);
                     object_touch(actor);
                     object_touch(actor);
                 }
                 }
             }
             }

+ 7 - 4
data.c

@@ -3233,7 +3233,7 @@ xs_list *content_search(snac *user, const char *regex,
 }
 }
 
 
 
 
-int actor_failure(const char *actor, int op)
+int actor_failure(const char *actor, snac_op op)
 /* actor failure maintenance */
 /* actor failure maintenance */
 {
 {
     int ret = 0;
     int ret = 0;
@@ -3242,13 +3242,13 @@ int actor_failure(const char *actor, int op)
     xs *fn = xs_fmt("%s/failure/%s", srv_basedir, md5);
     xs *fn = xs_fmt("%s/failure/%s", srv_basedir, md5);
 
 
     switch (op) {
     switch (op) {
-    case 0: /** check **/
+    case OP_CHECK: /** check **/
         if (mtime(fn))
         if (mtime(fn))
             ret = -1;
             ret = -1;
 
 
         break;
         break;
 
 
-    case 1: /** register a failure **/
+    case OP_ADD: /** register a failure **/
         if (mtime(fn) == 0.0) {
         if (mtime(fn) == 0.0) {
             FILE *f;
             FILE *f;
 
 
@@ -3261,11 +3261,14 @@ int actor_failure(const char *actor, int op)
 
 
         break;
         break;
 
 
-    case 2: /** clear a failure **/
+    case OP_DEL: /** clear a failure **/
         /* called whenever a message comes from this instance */
         /* called whenever a message comes from this instance */
         unlink(fn);
         unlink(fn);
 
 
         break;
         break;
+
+    default:
+        break;
     }
     }
 
 
     return ret;
     return ret;

+ 1 - 1
html.c

@@ -362,7 +362,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
                 xs_html_raw("💔")));
                 xs_html_raw("💔")));
     }
     }
 
 
-    if (actor_failure(actor_id, 0) == -1) {
+    if (actor_failure(actor_id, OP_CHECK) == -1) {
         xs_html_add(actor_icon,
         xs_html_add(actor_icon,
             xs_html_text(" "),
             xs_html_text(" "),
             xs_html_tag("span",
             xs_html_tag("span",

+ 9 - 1
snac.h

@@ -79,6 +79,14 @@ typedef struct {
     enum { THST_STOP, THST_WAIT, THST_IN, THST_QUEUE } th_state[MAX_THREADS];
     enum { THST_STOP, THST_WAIT, THST_IN, THST_QUEUE } th_state[MAX_THREADS];
 } srv_state;
 } srv_state;
 
 
+typedef enum {
+    OP_CHECK = 0,
+    OP_ADD = 1,
+    OP_DEL = 2,
+    OP_LIST = 3,
+    OP_FIND = 4
+} snac_op;
+
 extern srv_state *p_state;
 extern srv_state *p_state;
 
 
 enum {
 enum {
@@ -300,7 +308,7 @@ int content_match(const char *file, const xs_dict *msg);
 xs_list *content_search(snac *user, const char *regex,
 xs_list *content_search(snac *user, const char *regex,
             int priv, int skip, int show, int max_secs, int *timeout);
             int priv, int skip, int show, int max_secs, int *timeout);
 
 
-int actor_failure(const char *actor, int op);
+int actor_failure(const char *actor, snac_op op);
 int instance_failure(const char *url, int op);
 int instance_failure(const char *url, int op);
 
 
 int grave(const char *objid, int op);
 int grave(const char *objid, int op);