summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorGravatar default2024-05-21 14:12:15 +0200
committerGravatar default2024-05-21 14:12:15 +0200
commit4777fc86cb962917a8f34afb3bfa40f26290815d (patch)
tree268c078531a018f07c1b6d029f14f87134805f7b /data.c
parentVersion 2.53 RELEASED. (diff)
downloadsnac2-4777fc86cb962917a8f34afb3bfa40f26290815d.tar.gz
snac2-4777fc86cb962917a8f34afb3bfa40f26290815d.tar.xz
snac2-4777fc86cb962917a8f34afb3bfa40f26290815d.zip
Added const everywhere.
Diffstat (limited to 'data.c')
-rw-r--r--data.c130
1 files changed, 49 insertions, 81 deletions
diff --git a/data.c b/data.c
index 0cceefd..3377f3e 100644
--- a/data.c
+++ b/data.c
@@ -29,7 +29,7 @@ pthread_mutex_t data_mutex = {0};
29int snac_upgrade(xs_str **error); 29int snac_upgrade(xs_str **error);
30 30
31 31
32int srv_open(char *basedir, int auto_upgrade) 32int srv_open(const char *basedir, int auto_upgrade)
33/* opens a server */ 33/* opens a server */
34{ 34{
35 int ret = 0; 35 int ret = 0;
@@ -58,10 +58,10 @@ int srv_open(char *basedir, int auto_upgrade)
58 if (srv_config == NULL) 58 if (srv_config == NULL)
59 error = xs_fmt("ERROR: cannot parse '%s'", cfg_file); 59 error = xs_fmt("ERROR: cannot parse '%s'", cfg_file);
60 else { 60 else {
61 char *host; 61 const char *host;
62 char *prefix; 62 const char *prefix;
63 char *dbglvl; 63 const char *dbglvl;
64 char *proto; 64 const char *proto;
65 65
66 host = xs_dict_get(srv_config, "host"); 66 host = xs_dict_get(srv_config, "host");
67 prefix = xs_dict_get(srv_config, "prefix"); 67 prefix = xs_dict_get(srv_config, "prefix");
@@ -710,7 +710,7 @@ int _object_add(const char *id, const xs_dict *obj, int ow)
710 fclose(f); 710 fclose(f);
711 711
712 /* does this object has a parent? */ 712 /* does this object has a parent? */
713 char *in_reply_to = xs_dict_get(obj, "inReplyTo"); 713 const char *in_reply_to = xs_dict_get(obj, "inReplyTo");
714 714
715 if (!xs_is_null(in_reply_to) && *in_reply_to) { 715 if (!xs_is_null(in_reply_to) && *in_reply_to) {
716 /* update the children index of the parent */ 716 /* update the children index of the parent */
@@ -1124,7 +1124,7 @@ int timeline_get_by_md5(snac *snac, const char *md5, xs_dict **msg)
1124} 1124}
1125 1125
1126 1126
1127int timeline_del(snac *snac, char *id) 1127int timeline_del(snac *snac, const char *id)
1128/* deletes a message from the timeline */ 1128/* deletes a message from the timeline */
1129{ 1129{
1130 /* delete from the user's caches */ 1130 /* delete from the user's caches */
@@ -1192,17 +1192,16 @@ int timeline_admire(snac *snac, const char *id, const char *admirer, int like)
1192} 1192}
1193 1193
1194 1194
1195xs_list *timeline_top_level(snac *snac, xs_list *list) 1195xs_list *timeline_top_level(snac *snac, const xs_list *list)
1196/* returns the top level md5 entries from this index */ 1196/* returns the top level md5 entries from this index */
1197{ 1197{
1198 xs_set seen; 1198 xs_set seen;
1199 xs_list *p;
1200 xs_str *v; 1199 xs_str *v;
1201 1200
1202 xs_set_init(&seen); 1201 xs_set_init(&seen);
1203 1202
1204 p = list; 1203 int c = 0;
1205 while (xs_list_iter(&p, &v)) { 1204 while (xs_list_next(list, &v, &c)) {
1206 char line[256] = ""; 1205 char line[256] = "";
1207 1206
1208 strncpy(line, v, sizeof(line)); 1207 strncpy(line, v, sizeof(line));
@@ -1290,7 +1289,7 @@ int following_add(snac *snac, const char *actor, const xs_dict *msg)
1290 /* object already exists; if it's of type Accept, 1289 /* object already exists; if it's of type Accept,
1291 the actor is already being followed and confirmed, 1290 the actor is already being followed and confirmed,
1292 so do nothing */ 1291 so do nothing */
1293 char *type = xs_dict_get(p_object, "type"); 1292 const char *type = xs_dict_get(p_object, "type");
1294 1293
1295 if (!xs_is_null(type) && strcmp(type, "Accept") == 0) { 1294 if (!xs_is_null(type) && strcmp(type, "Accept") == 0) {
1296 snac_debug(snac, 1, xs_fmt("following_add actor already confirmed %s", actor)); 1295 snac_debug(snac, 1, xs_fmt("following_add actor already confirmed %s", actor));
@@ -1546,8 +1545,9 @@ void hide(snac *snac, const char *id)
1546 1545
1547 /* resolve to get the id */ 1546 /* resolve to get the id */
1548 if (valid_status(object_get_by_md5(v, &co))) { 1547 if (valid_status(object_get_by_md5(v, &co))) {
1549 if ((v = xs_dict_get(co, "id")) != NULL) 1548 const char *id = xs_dict_get(co, "id");
1550 hide(snac, v); 1549 if (id != NULL)
1550 hide(snac, id);
1551 } 1551 }
1552 } 1552 }
1553 } 1553 }
@@ -1563,7 +1563,7 @@ int is_hidden(snac *snac, const char *id)
1563} 1563}
1564 1564
1565 1565
1566int actor_add(const char *actor, xs_dict *msg) 1566int actor_add(const char *actor, const xs_dict *msg)
1567/* adds an actor */ 1567/* adds an actor */
1568{ 1568{
1569 return object_add_ow(actor, msg); 1569 return object_add_ow(actor, msg);
@@ -1687,7 +1687,7 @@ int limited(snac *user, const char *id, int cmd)
1687void tag_index(const char *id, const xs_dict *obj) 1687void tag_index(const char *id, const xs_dict *obj)
1688/* update the tag indexes for this object */ 1688/* update the tag indexes for this object */
1689{ 1689{
1690 xs_list *tags = xs_dict_get(obj, "tag"); 1690 const xs_list *tags = xs_dict_get(obj, "tag");
1691 1691
1692 if (is_msg_public(obj) && xs_type(tags) == XSTYPE_LIST && xs_list_len(tags) > 0) { 1692 if (is_msg_public(obj) && xs_type(tags) == XSTYPE_LIST && xs_list_len(tags) > 0) {
1693 xs *g_tag_dir = xs_fmt("%s/tag", srv_basedir); 1693 xs *g_tag_dir = xs_fmt("%s/tag", srv_basedir);
@@ -1695,9 +1695,10 @@ void tag_index(const char *id, const xs_dict *obj)
1695 mkdirx(g_tag_dir); 1695 mkdirx(g_tag_dir);
1696 1696
1697 xs_dict *v; 1697 xs_dict *v;
1698 while (xs_list_iter(&tags, &v)) { 1698 int ct = 0;
1699 char *type = xs_dict_get(v, "type"); 1699 while (xs_list_next(tags, &v, &ct)) {
1700 char *name = xs_dict_get(v, "name"); 1700 const char *type = xs_dict_get(v, "type");
1701 const char *name = xs_dict_get(v, "name");
1701 1702
1702 if (!xs_is_null(type) && !xs_is_null(name) && strcmp(type, "Hashtag") == 0) { 1703 if (!xs_is_null(type) && !xs_is_null(name) && strcmp(type, "Hashtag") == 0) {
1703 while (*name == '#' || *name == '@') 1704 while (*name == '#' || *name == '@')
@@ -1706,7 +1707,7 @@ void tag_index(const char *id, const xs_dict *obj)
1706 if (*name == '\0') 1707 if (*name == '\0')
1707 continue; 1708 continue;
1708 1709
1709 name = xs_tolower_i(name); 1710 name = xs_tolower_i((xs_str *)name);
1710 1711
1711 xs *md5_tag = xs_md5_hex(name, strlen(name)); 1712 xs *md5_tag = xs_md5_hex(name, strlen(name));
1712 xs *tag_dir = xs_fmt("%s/%c%c", g_tag_dir, md5_tag[0], md5_tag[1]); 1713 xs *tag_dir = xs_fmt("%s/%c%c", g_tag_dir, md5_tag[0], md5_tag[1]);
@@ -1729,7 +1730,7 @@ void tag_index(const char *id, const xs_dict *obj)
1729} 1730}
1730 1731
1731 1732
1732xs_list *tag_search(char *tag, int skip, int show) 1733xs_list *tag_search(const char *tag, int skip, int show)
1733/* returns the list of posts tagged with tag */ 1734/* returns the list of posts tagged with tag */
1734{ 1735{
1735 if (*tag == '#') 1736 if (*tag == '#')
@@ -1912,7 +1913,7 @@ xs_val *list_content(snac *user, const char *list, const char *actor_md5, int op
1912void list_distribute(snac *user, const char *who, const xs_dict *post) 1913void list_distribute(snac *user, const char *who, const xs_dict *post)
1913/* distributes the post to all appropriate lists */ 1914/* distributes the post to all appropriate lists */
1914{ 1915{
1915 char *id = xs_dict_get(post, "id"); 1916 const char *id = xs_dict_get(post, "id");
1916 1917
1917 /* if who is not set, use the attributedTo in the message */ 1918 /* if who is not set, use the attributedTo in the message */
1918 if (xs_is_null(who)) 1919 if (xs_is_null(who))
@@ -2164,7 +2165,7 @@ void inbox_add(const char *inbox)
2164void inbox_add_by_actor(const xs_dict *actor) 2165void inbox_add_by_actor(const xs_dict *actor)
2165/* collects an actor's shared inbox, if it has one */ 2166/* collects an actor's shared inbox, if it has one */
2166{ 2167{
2167 char *v; 2168 const char *v;
2168 2169
2169 if (!xs_is_null(v = xs_dict_get(actor, "endpoints")) && 2170 if (!xs_is_null(v = xs_dict_get(actor, "endpoints")) &&
2170 !xs_is_null(v = xs_dict_get(v, "sharedInbox"))) { 2171 !xs_is_null(v = xs_dict_get(v, "sharedInbox"))) {
@@ -2210,7 +2211,7 @@ xs_str *_instance_block_fn(const char *instance)
2210 xs *s = xs_replace(instance, "http:/" "/", ""); 2211 xs *s = xs_replace(instance, "http:/" "/", "");
2211 xs *s1 = xs_replace(s, "https:/" "/", ""); 2212 xs *s1 = xs_replace(s, "https:/" "/", "");
2212 xs *l = xs_split(s1, "/"); 2213 xs *l = xs_split(s1, "/");
2213 char *p = xs_list_get(l, 0); 2214 const char *p = xs_list_get(l, 0);
2214 xs *md5 = xs_md5_hex(p, strlen(p)); 2215 xs *md5 = xs_md5_hex(p, strlen(p));
2215 2216
2216 return xs_fmt("%s/block/%s", srv_basedir, md5); 2217 return xs_fmt("%s/block/%s", srv_basedir, md5);
@@ -2279,7 +2280,7 @@ int content_match(const char *file, const xs_dict *msg)
2279 xs *fn = xs_fmt("%s/%s", srv_basedir, file); 2280 xs *fn = xs_fmt("%s/%s", srv_basedir, file);
2280 FILE *f; 2281 FILE *f;
2281 int r = 0; 2282 int r = 0;
2282 char *v = xs_dict_get(msg, "content"); 2283 const char *v = xs_dict_get(msg, "content");
2283 2284
2284 if (xs_type(v) == XSTYPE_STRING && *v) { 2285 if (xs_type(v) == XSTYPE_STRING && *v) {
2285 if ((f = fopen(fn, "r")) != NULL) { 2286 if ((f = fopen(fn, "r")) != NULL) {
@@ -2386,7 +2387,7 @@ xs_list *content_search(snac *user, const char *regex,
2386 if (id == NULL || is_hidden(user, id)) 2387 if (id == NULL || is_hidden(user, id))
2387 continue; 2388 continue;
2388 2389
2389 char *content = xs_dict_get(post, "content"); 2390 const char *content = xs_dict_get(post, "content");
2390 2391
2391 if (xs_is_null(content)) 2392 if (xs_is_null(content))
2392 continue; 2393 continue;
@@ -2639,7 +2640,7 @@ void enqueue_input(snac *snac, const xs_dict *msg, const xs_dict *req, int retri
2639/* enqueues an input message */ 2640/* enqueues an input message */
2640{ 2641{
2641 xs *qmsg = _new_qmsg("input", msg, retries); 2642 xs *qmsg = _new_qmsg("input", msg, retries);
2642 char *ntid = xs_dict_get(qmsg, "ntid"); 2643 const char *ntid = xs_dict_get(qmsg, "ntid");
2643 xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid); 2644 xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
2644 2645
2645 qmsg = xs_dict_append(qmsg, "req", req); 2646 qmsg = xs_dict_append(qmsg, "req", req);
@@ -2654,7 +2655,7 @@ void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries)
2654/* enqueues an input message from the shared input */ 2655/* enqueues an input message from the shared input */
2655{ 2656{
2656 xs *qmsg = _new_qmsg("input", msg, retries); 2657 xs *qmsg = _new_qmsg("input", msg, retries);
2657 char *ntid = xs_dict_get(qmsg, "ntid"); 2658 const char *ntid = xs_dict_get(qmsg, "ntid");
2658 xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid); 2659 xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid);
2659 2660
2660 qmsg = xs_dict_append(qmsg, "req", req); 2661 qmsg = xs_dict_append(qmsg, "req", req);
@@ -2666,11 +2667,12 @@ void enqueue_shared_input(const xs_dict *msg, const xs_dict *req, int retries)
2666 2667
2667 2668
2668void enqueue_output_raw(const char *keyid, const char *seckey, 2669void enqueue_output_raw(const char *keyid, const char *seckey,
2669 xs_dict *msg, xs_str *inbox, int retries, int p_status) 2670 const xs_dict *msg, const xs_str *inbox,
2671 int retries, int p_status)
2670/* enqueues an output message to an inbox */ 2672/* enqueues an output message to an inbox */
2671{ 2673{
2672 xs *qmsg = _new_qmsg("output", msg, retries); 2674 xs *qmsg = _new_qmsg("output", msg, retries);
2673 char *ntid = xs_dict_get(qmsg, "ntid"); 2675 const char *ntid = xs_dict_get(qmsg, "ntid");
2674 xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid); 2676 xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid);
2675 2677
2676 xs *ns = xs_number_new(p_status); 2678 xs *ns = xs_number_new(p_status);
@@ -2690,7 +2692,8 @@ void enqueue_output_raw(const char *keyid, const char *seckey,
2690} 2692}
2691 2693
2692 2694
2693void enqueue_output(snac *snac, xs_dict *msg, xs_str *inbox, int retries, int p_status) 2695void enqueue_output(snac *snac, const xs_dict *msg,
2696 const xs_str *inbox, int retries, int p_status)
2694/* enqueues an output message to an inbox */ 2697/* enqueues an output message to an inbox */
2695{ 2698{
2696 if (xs_startswith(inbox, snac->actor)) { 2699 if (xs_startswith(inbox, snac->actor)) {
@@ -2698,13 +2701,14 @@ void enqueue_output(snac *snac, xs_dict *msg, xs_str *inbox, int retries, int p_
2698 return; 2701 return;
2699 } 2702 }
2700 2703
2701 char *seckey = xs_dict_get(snac->key, "secret"); 2704 const char *seckey = xs_dict_get(snac->key, "secret");
2702 2705
2703 enqueue_output_raw(snac->actor, seckey, msg, inbox, retries, p_status); 2706 enqueue_output_raw(snac->actor, seckey, msg, inbox, retries, p_status);
2704} 2707}
2705 2708
2706 2709
2707void enqueue_output_by_actor(snac *snac, xs_dict *msg, const xs_str *actor, int retries) 2710void enqueue_output_by_actor(snac *snac, const xs_dict *msg,
2711 const xs_str *actor, int retries)
2708/* enqueues an output message for an actor */ 2712/* enqueues an output message for an actor */
2709{ 2713{
2710 xs *inbox = get_actor_inbox(actor); 2714 xs *inbox = get_actor_inbox(actor);
@@ -2716,11 +2720,11 @@ void enqueue_output_by_actor(snac *snac, xs_dict *msg, const xs_str *actor, int
2716} 2720}
2717 2721
2718 2722
2719void enqueue_email(xs_str *msg, int retries) 2723void enqueue_email(const xs_str *msg, int retries)
2720/* enqueues an email message to be sent */ 2724/* enqueues an email message to be sent */
2721{ 2725{
2722 xs *qmsg = _new_qmsg("email", msg, retries); 2726 xs *qmsg = _new_qmsg("email", msg, retries);
2723 char *ntid = xs_dict_get(qmsg, "ntid"); 2727 const char *ntid = xs_dict_get(qmsg, "ntid");
2724 xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid); 2728 xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid);
2725 2729
2726 qmsg = _enqueue_put(fn, qmsg); 2730 qmsg = _enqueue_put(fn, qmsg);
@@ -2733,7 +2737,7 @@ void enqueue_telegram(const xs_str *msg, const char *bot, const char *chat_id)
2733/* enqueues a message to be sent via Telegram */ 2737/* enqueues a message to be sent via Telegram */
2734{ 2738{
2735 xs *qmsg = _new_qmsg("telegram", msg, 0); 2739 xs *qmsg = _new_qmsg("telegram", msg, 0);
2736 char *ntid = xs_dict_get(qmsg, "ntid"); 2740 const char *ntid = xs_dict_get(qmsg, "ntid");
2737 xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid); 2741 xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid);
2738 2742
2739 qmsg = xs_dict_append(qmsg, "bot", bot); 2743 qmsg = xs_dict_append(qmsg, "bot", bot);
@@ -2748,7 +2752,7 @@ void enqueue_ntfy(const xs_str *msg, const char *ntfy_server, const char *ntfy_t
2748/* enqueues a message to be sent via ntfy */ 2752/* enqueues a message to be sent via ntfy */
2749{ 2753{
2750 xs *qmsg = _new_qmsg("ntfy", msg, 0); 2754 xs *qmsg = _new_qmsg("ntfy", msg, 0);
2751 char *ntid = xs_dict_get(qmsg, "ntid"); 2755 const char *ntid = xs_dict_get(qmsg, "ntid");
2752 xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid); 2756 xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid);
2753 2757
2754 qmsg = xs_dict_append(qmsg, "ntfy_server", ntfy_server); 2758 qmsg = xs_dict_append(qmsg, "ntfy_server", ntfy_server);
@@ -2764,7 +2768,7 @@ void enqueue_message(snac *snac, const xs_dict *msg)
2764/* enqueues an output message */ 2768/* enqueues an output message */
2765{ 2769{
2766 xs *qmsg = _new_qmsg("message", msg, 0); 2770 xs *qmsg = _new_qmsg("message", msg, 0);
2767 char *ntid = xs_dict_get(qmsg, "ntid"); 2771 const char *ntid = xs_dict_get(qmsg, "ntid");
2768 xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid); 2772 xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
2769 2773
2770 qmsg = _enqueue_put(fn, qmsg); 2774 qmsg = _enqueue_put(fn, qmsg);
@@ -2807,7 +2811,7 @@ void enqueue_verify_links(snac *user)
2807/* enqueues a link verification */ 2811/* enqueues a link verification */
2808{ 2812{
2809 xs *qmsg = _new_qmsg("verify_links", "", 0); 2813 xs *qmsg = _new_qmsg("verify_links", "", 0);
2810 char *ntid = xs_dict_get(qmsg, "ntid"); 2814 const char *ntid = xs_dict_get(qmsg, "ntid");
2811 xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid); 2815 xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid);
2812 2816
2813 qmsg = _enqueue_put(fn, qmsg); 2817 qmsg = _enqueue_put(fn, qmsg);
@@ -2832,42 +2836,6 @@ void enqueue_actor_refresh(snac *user, const char *actor, int forward_secs)
2832} 2836}
2833 2837
2834 2838
2835void enqueue_request_replies(snac *user, const char *id)
2836/* enqueues a request for the replies of a message */
2837{
2838 /* test first if this precise request is already in the queue */
2839 xs *queue = user_queue(user);
2840 xs_list *p = queue;
2841 xs_str *v;
2842
2843 while (xs_list_iter(&p, &v)) {
2844 xs *q_item = queue_get(v);
2845
2846 if (q_item != NULL) {
2847 const char *type = xs_dict_get(q_item, "type");
2848 const char *msg = xs_dict_get(q_item, "message");
2849
2850 if (type && msg && strcmp(type, "request_replies") == 0 && strcmp(msg, id) == 0) {
2851 /* don't requeue */
2852 snac_debug(user, 1, xs_fmt("enqueue_request_replies already here %s", id));
2853 return;
2854 }
2855 }
2856 }
2857
2858 /* not there; enqueue the request with a small delay */
2859 xs *qmsg = _new_qmsg("request_replies", id, 0);
2860 xs *ntid = tid(10);
2861 xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid);
2862
2863 qmsg = xs_dict_set(qmsg, "ntid", ntid);
2864
2865 qmsg = _enqueue_put(fn, qmsg);
2866
2867 snac_debug(user, 2, xs_fmt("enqueue_request_replies %s", id));
2868}
2869
2870
2871int was_question_voted(snac *user, const char *id) 2839int was_question_voted(snac *user, const char *id)
2872/* returns true if the user voted in this poll */ 2840/* returns true if the user voted in this poll */
2873{ 2841{
@@ -2881,7 +2849,7 @@ int was_question_voted(snac *user, const char *id)
2881 xs *obj = NULL; 2849 xs *obj = NULL;
2882 2850
2883 if (valid_status(object_get_by_md5(md5, &obj))) { 2851 if (valid_status(object_get_by_md5(md5, &obj))) {
2884 char *atto = get_atto(obj); 2852 const char *atto = get_atto(obj);
2885 if (atto && strcmp(atto, user->actor) == 0 && 2853 if (atto && strcmp(atto, user->actor) == 0 &&
2886 !xs_is_null(xs_dict_get(obj, "name"))) { 2854 !xs_is_null(xs_dict_get(obj, "name"))) {
2887 voted = 1; 2855 voted = 1;
@@ -3055,7 +3023,7 @@ void purge_server(void)
3055 if (mtime_nl(v2, &n_link) < mt && n_link < 2) { 3023 if (mtime_nl(v2, &n_link) < mt && n_link < 2) {
3056 xs *s1 = xs_replace(v2, ".json", ""); 3024 xs *s1 = xs_replace(v2, ".json", "");
3057 xs *l = xs_split(s1, "/"); 3025 xs *l = xs_split(s1, "/");
3058 char *md5 = xs_list_get(l, -1); 3026 const char *md5 = xs_list_get(l, -1);
3059 3027
3060 object_del_by_md5(md5); 3028 object_del_by_md5(md5);
3061 cnt++; 3029 cnt++;
@@ -3147,7 +3115,7 @@ void purge_user(snac *snac)
3147/* do the purge for this user */ 3115/* do the purge for this user */
3148{ 3116{
3149 int priv_days, pub_days, user_days = 0; 3117 int priv_days, pub_days, user_days = 0;
3150 char *v; 3118 const char *v;
3151 int n; 3119 int n;
3152 3120
3153 priv_days = xs_number_get(xs_dict_get(srv_config, "timeline_purge_days")); 3121 priv_days = xs_number_get(xs_dict_get(srv_config, "timeline_purge_days"));
@@ -3256,7 +3224,7 @@ void srv_archive(const char *direction, const char *url, xs_dict *req,
3256 if (p_size && payload) { 3224 if (p_size && payload) {
3257 xs *payload_fn = NULL; 3225 xs *payload_fn = NULL;
3258 xs *payload_fn_raw = NULL; 3226 xs *payload_fn_raw = NULL;
3259 char *v = xs_dict_get(req, "content-type"); 3227 const char *v = xs_dict_get(req, "content-type");
3260 3228
3261 if (v && xs_str_in(v, "json") != -1) { 3229 if (v && xs_str_in(v, "json") != -1) {
3262 payload_fn = xs_fmt("%s/payload.json", dir); 3230 payload_fn = xs_fmt("%s/payload.json", dir);
@@ -3287,7 +3255,7 @@ void srv_archive(const char *direction, const char *url, xs_dict *req,
3287 3255
3288 if (b_size && body) { 3256 if (b_size && body) {
3289 xs *body_fn = NULL; 3257 xs *body_fn = NULL;
3290 char *v = xs_dict_get(headers, "content-type"); 3258 const char *v = xs_dict_get(headers, "content-type");
3291 3259
3292 if (v && xs_str_in(v, "json") != -1) { 3260 if (v && xs_str_in(v, "json") != -1) {
3293 body_fn = xs_fmt("%s/body.json", dir); 3261 body_fn = xs_fmt("%s/body.json", dir);
@@ -3356,7 +3324,7 @@ void srv_archive_error(const char *prefix, const xs_str *err,
3356} 3324}
3357 3325
3358 3326
3359void srv_archive_qitem(char *prefix, xs_dict *q_item) 3327void srv_archive_qitem(const char *prefix, xs_dict *q_item)
3360/* archives a q_item in the error folder */ 3328/* archives a q_item in the error folder */
3361{ 3329{
3362 xs *ntid = tid(0); 3330 xs *ntid = tid(0);