summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--activitypub.c25
-rw-r--r--data.c39
-rw-r--r--format.c6
-rw-r--r--httpd.c6
-rw-r--r--mastoapi.c2
-rw-r--r--snac.h1
-rw-r--r--utils.c6
7 files changed, 69 insertions, 16 deletions
diff --git a/activitypub.c b/activitypub.c
index 1efd9ec..4ed2805 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -17,25 +17,25 @@
17 17
18#include <sys/wait.h> 18#include <sys/wait.h>
19 19
20const char *public_address = "https:/" "/www.w3.org/ns/activitystreams#Public"; 20const char * const public_address = "https:/" "/www.w3.org/ns/activitystreams#Public";
21 21
22/* susie.png */ 22/* susie.png */
23 23
24const char *susie = 24const char * const susie =
25 "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQAAAAC" 25 "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQAAAAC"
26 "CEkxzAAAAUUlEQVQoz43R0QkAMQwCUDdw/y3dwE" 26 "CEkxzAAAAUUlEQVQoz43R0QkAMQwCUDdw/y3dwE"
27 "vsvzlL4X1IoQkAisKmwfAFT3RgJHbQezpSRoXEq" 27 "vsvzlL4X1IoQkAisKmwfAFT3RgJHbQezpSRoXEq"
28 "eqCL9BJBf7h3QbOCCxV5EVWMEMwG7K1/WODtlvx" 28 "eqCL9BJBf7h3QbOCCxV5EVWMEMwG7K1/WODtlvx"
29 "AYTtEsDU9F34AAAAAElFTkSuQmCC"; 29 "AYTtEsDU9F34AAAAAElFTkSuQmCC";
30 30
31const char *susie_cool = 31const char * const susie_cool =
32 "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQAAAAC" 32 "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQAAAAC"
33 "CEkxzAAAAV0lEQVQoz43RwQ3AMAwCQDZg/y3ZgN" 33 "CEkxzAAAAV0lEQVQoz43RwQ3AMAwCQDZg/y3ZgN"
34 "qo3+JaedwDOUQBQFHYaTB8wTM6sGl2cMPu+DFzn" 34 "qo3+JaedwDOUQBQFHYaTB8wTM6sGl2cMPu+DFzn"
35 "+ZcgN7wF7ZVihXkfSlWIVzIA6dbQzaygllpNuTX" 35 "+ZcgN7wF7ZVihXkfSlWIVzIA6dbQzaygllpNuTX"
36 "ZmmFNlvxADX1+o0cUPMbAAAAAElFTkSuQmCC"; 36 "ZmmFNlvxADX1+o0cUPMbAAAAAElFTkSuQmCC";
37 37
38const char *susie_muertos = 38const char * const susie_muertos =
39 "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQAAAAC" 39 "iVBORw0KGgoAAAANSUhEUgAAAEAAAABAAQAAAAC"
40 "CEkxzAAAAV0lEQVQoz4XQsQ0AMQxCUW/A/lv+DT" 40 "CEkxzAAAAV0lEQVQoz4XQsQ0AMQxCUW/A/lv+DT"
41 "ic6zGRolekIMyMELNp8PiCEw6Q4w4NoAt53IH5m" 41 "ic6zGRolekIMyMELNp8PiCEw6Q4w4NoAt53IH5m"
@@ -3101,6 +3101,11 @@ void process_user_queue_item(snac *user, xs_dict *q_item)
3101 const char *actor = xs_dict_get(q_item, "actor"); 3101 const char *actor = xs_dict_get(q_item, "actor");
3102 double mtime = object_mtime(actor); 3102 double mtime = object_mtime(actor);
3103 3103
3104 if (actor_failure(actor, 0) == -1) {
3105 /* actor is broken beyond repair */
3106 snac_debug(user, 1, xs_fmt("actor_refresh skipped broken actor %s", actor));
3107 }
3108 else
3104 /* only refresh if it was refreshed more than an hour ago */ 3109 /* only refresh if it was refreshed more than an hour ago */
3105 if (mtime + 3600.0 < (double) time(NULL)) { 3110 if (mtime + 3600.0 < (double) time(NULL)) {
3106 xs *actor_o = NULL; 3111 xs *actor_o = NULL;
@@ -3108,8 +3113,16 @@ void process_user_queue_item(snac *user, xs_dict *q_item)
3108 3113
3109 if (valid_status((status = activitypub_request(user, actor, &actor_o)))) 3114 if (valid_status((status = activitypub_request(user, actor, &actor_o))))
3110 actor_add(actor, actor_o); 3115 actor_add(actor, actor_o);
3111 else 3116 else {
3112 object_touch(actor); 3117 if (status == HTTP_STATUS_GONE) {
3118 actor_failure(actor, 1);
3119 snac_log(user, xs_fmt("actor_refresh marking actor %s as broken %d", actor, status));
3120 }
3121 else {
3122 actor_failure(actor, 2);
3123 object_touch(actor);
3124 }
3125 }
3113 3126
3114 snac_log(user, xs_fmt("actor_refresh %s %d", actor, status)); 3127 snac_log(user, xs_fmt("actor_refresh %s %d", actor, status));
3115 } 3128 }
diff --git a/data.c b/data.c
index 9ef0d42..53e9438 100644
--- a/data.c
+++ b/data.c
@@ -3046,6 +3046,45 @@ xs_list *content_search(snac *user, const char *regex,
3046} 3046}
3047 3047
3048 3048
3049int actor_failure(const char *actor, int op)
3050/* actor failure maintenance */
3051{
3052 int ret = 0;
3053
3054 xs *md5 = xs_md5_hex(actor, strlen(actor));
3055 xs *fn = xs_fmt("%s/failure/%s", srv_basedir, md5);
3056
3057 switch (op) {
3058 case 0: /** check **/
3059 if (mtime(fn))
3060 ret = -1;
3061
3062 break;
3063
3064 case 1: /** register a failure **/
3065 if (mtime(fn) == 0.0) {
3066 FILE *f;
3067
3068 /* only create once, as the date will be used */
3069 if ((f = fopen(fn, "w")) != NULL) {
3070 fprintf(f, "%s\n", actor);
3071 fclose(f);
3072 }
3073 }
3074
3075 break;
3076
3077 case 2: /** clear a failure **/
3078 /* called whenever a message comes from this instance */
3079 unlink(fn);
3080
3081 break;
3082 }
3083
3084 return ret;
3085}
3086
3087
3049int instance_failure(const char *url, int op) 3088int instance_failure(const char *url, int op)
3050/* do some checks and accounting on instance failures */ 3089/* do some checks and accounting on instance failures */
3051{ 3090{
diff --git a/format.c b/format.c
index e3f20c2..84c634d 100644
--- a/format.c
+++ b/format.c
@@ -13,7 +13,7 @@
13#include "snac.h" 13#include "snac.h"
14 14
15/* emoticons, people laughing and such */ 15/* emoticons, people laughing and such */
16const char *smileys[] = { 16const char * const smileys[] = {
17 ":-)", "&#128578;", 17 ":-)", "&#128578;",
18 ":-D", "&#128512;", 18 ":-D", "&#128512;",
19 "X-D", "&#128518;", 19 "X-D", "&#128518;",
@@ -49,7 +49,7 @@ xs_dict *emojis(void)
49 if (mtime(fn) == 0) { 49 if (mtime(fn) == 0) {
50 /* file does not exist; create it with the defaults */ 50 /* file does not exist; create it with the defaults */
51 xs *d = xs_dict_new(); 51 xs *d = xs_dict_new();
52 const char **emo = smileys; 52 const char * const *emo = smileys;
53 53
54 while (*emo) { 54 while (*emo) {
55 d = xs_dict_append(d, emo[0], emo[1]); 55 d = xs_dict_append(d, emo[0], emo[1]);
@@ -443,7 +443,7 @@ xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag
443} 443}
444 444
445 445
446const char *valid_tags[] = { 446const char * const valid_tags[] = {
447 "a", "p", "br", "br/", "blockquote", "ul", "ol", "li", "cite", "small", 447 "a", "p", "br", "br/", "blockquote", "ul", "ol", "li", "cite", "small",
448 "span", "i", "b", "u", "s", "pre", "code", "em", "strong", "hr", "img", "del", "bdi", 448 "span", "i", "b", "u", "s", "pre", "code", "em", "strong", "hr", "img", "del", "bdi",
449 "h2","h3", //anzu 449 "h2","h3", //anzu
diff --git a/httpd.c b/httpd.c
index 50f56f2..de76776 100644
--- a/httpd.c
+++ b/httpd.c
@@ -59,7 +59,7 @@ static jmp_buf on_break;
59/** code **/ 59/** code **/
60 60
61/* nodeinfo 2.0 template */ 61/* nodeinfo 2.0 template */
62const char *nodeinfo_2_0_template = "" 62const char * const nodeinfo_2_0_template = ""
63 "{\"version\":\"2.0\"," 63 "{\"version\":\"2.0\","
64 "\"software\":{\"name\":\"snac\",\"version\":\"" VERSION "\"}," 64 "\"software\":{\"name\":\"snac\",\"version\":\"" VERSION "\"},"
65 "\"protocols\":[\"activitypub\"]," 65 "\"protocols\":[\"activitypub\"],"
@@ -172,7 +172,7 @@ static xs_str *greeting_html(void)
172} 172}
173 173
174 174
175const char *share_page = "" 175const char * const share_page = ""
176"<!DOCTYPE html>\n" 176"<!DOCTYPE html>\n"
177"<html>\n" 177"<html>\n"
178"<head>\n" 178"<head>\n"
@@ -190,7 +190,7 @@ const char *share_page = ""
190""; 190"";
191 191
192 192
193const char *authorize_interaction_page = "" 193const char * const authorize_interaction_page = ""
194"<!DOCTYPE html>\n" 194"<!DOCTYPE html>\n"
195"<html>\n" 195"<html>\n"
196"<head>\n" 196"<head>\n"
diff --git a/mastoapi.c b/mastoapi.c
index ed46b89..26af7d2 100644
--- a/mastoapi.c
+++ b/mastoapi.c
@@ -161,7 +161,7 @@ int token_del(const char *id)
161} 161}
162 162
163 163
164const char *login_page = "" 164const char * const login_page = ""
165"<!DOCTYPE html>\n" 165"<!DOCTYPE html>\n"
166"<html>\n" 166"<html>\n"
167"<head>\n" 167"<head>\n"
diff --git a/snac.h b/snac.h
index dc9d19a..5ed054a 100644
--- a/snac.h
+++ b/snac.h
@@ -285,6 +285,7 @@ int content_match(const char *file, const xs_dict *msg);
285xs_list *content_search(snac *user, const char *regex, 285xs_list *content_search(snac *user, const char *regex,
286 int priv, int skip, int show, int max_secs, int *timeout); 286 int priv, int skip, int show, int max_secs, int *timeout);
287 287
288int actor_failure(const char *actor, int op);
288int instance_failure(const char *url, int op); 289int instance_failure(const char *url, int op);
289 290
290void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries); 291void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retries);
diff --git a/utils.c b/utils.c
index bdee09d..38dcc06 100644
--- a/utils.c
+++ b/utils.c
@@ -16,7 +16,7 @@
16#include <sys/stat.h> 16#include <sys/stat.h>
17#include <stdlib.h> 17#include <stdlib.h>
18 18
19static const char *default_srv_config = "{" 19static const char * const default_srv_config = "{"
20 "\"host\": \"\"," 20 "\"host\": \"\","
21 "\"prefix\": \"\"," 21 "\"prefix\": \"\","
22 "\"address\": \"127.0.0.1\"," 22 "\"address\": \"127.0.0.1\","
@@ -42,7 +42,7 @@ static const char *default_srv_config = "{"
42 "\"fastcgi\": false" 42 "\"fastcgi\": false"
43 "}"; 43 "}";
44 44
45static const char *default_css = 45static const char * const default_css =
46 "body { max-width: 48em; margin: auto; line-height: 1.5; padding: 0.8em; word-wrap: break-word; }\n" 46 "body { max-width: 48em; margin: auto; line-height: 1.5; padding: 0.8em; word-wrap: break-word; }\n"
47 "pre { overflow-x: scroll; }\n" 47 "pre { overflow-x: scroll; }\n"
48 "blockquote { font-style: italic; }\n" 48 "blockquote { font-style: italic; }\n"
@@ -97,7 +97,7 @@ const char *snac_blurb =
97 "automatic sign-up process.</p>\n" 97 "automatic sign-up process.</p>\n"
98; 98;
99 99
100static const char *greeting_html = 100static const char * const greeting_html =
101 "<!DOCTYPE html>\n" 101 "<!DOCTYPE html>\n"
102 "<html><head>\n" 102 "<html><head>\n"
103 "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n" 103 "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n"