commit 335b90a

grunfink  ·  2025-09-28 12:26:18 +0000 UTC
parent 144eb7b
New function actor_failure().
2 files changed,  +19, -9
M data.c
M snac.h
M data.c
+18, -9
 1@@ -3042,18 +3042,13 @@ xs_list *content_search(snac *user, const char *regex,
 2 }
 3 
 4 
 5-int instance_failure(const char *url, int op)
 6-/* do some checks and accounting on instance failures */
 7+int actor_failure(const char *id, int op)
 8+/* actor failure maintenance */
 9 {
10     int ret = 0;
11-    xs *l = xs_split(url, "/");
12-    const char *hostname = xs_list_get(l, 2);
13     double mt;
14 
15-    if (!xs_is_string(hostname))
16-        return 0;
17-
18-    xs *md5 = xs_md5_hex(hostname, strlen(hostname));
19+    xs *md5 = xs_md5_hex(id, strlen(id));
20     xs *fn = xs_fmt("%s/failure/%s", srv_basedir, md5);
21 
22     switch (op) {
23@@ -3075,7 +3070,7 @@ int instance_failure(const char *url, int op)
24 
25             /* only create once, as the date will be used */
26             if ((f = fopen(fn, "w")) != NULL) {
27-                fprintf(f, "%s\n", hostname);
28+                fprintf(f, "%s\n", id);
29                 fclose(f);
30             }
31         }
32@@ -3093,6 +3088,20 @@ int instance_failure(const char *url, int op)
33 }
34 
35 
36+int instance_failure(const char *url, int op)
37+/* instance failure maintenance */
38+{
39+    /* extract just the host name */
40+    xs *l = xs_split(url, "/");
41+    const char *hostname = xs_list_get(l, 2);
42+
43+    if (!xs_is_string(hostname))
44+        return 0;
45+
46+    return actor_failure(hostname, op);
47+}
48+
49+
50 /** notifications **/
51 
52 xs_str *notify_check_time(snac *snac, int reset)
M snac.h
+1, -0
1@@ -278,6 +278,7 @@ int content_match(const char *file, const xs_dict *msg);
2 xs_list *content_search(snac *user, const char *regex,
3             int priv, int skip, int show, int max_secs, int *timeout);
4 
5+int actor_failure(const char *id, int op);
6 int instance_failure(const char *url, int op);
7 
8 void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries);