summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-09-23 19:37:01 +0200
committerdefault <nobody@localhost>2022-09-23 19:37:01 +0200
commitbbf5471039a973fed918441150ef76ff0db7682a (patch)
tree64d6fd0dbc63a2102fd1d2615bbcb85473f19f40 /data.c
parentcf59d68491bb4bf0954e8370354ba34994b6436f (diff)
New function process_queue().
Diffstat (limited to 'data.c')
-rw-r--r--data.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/data.c b/data.c
index c9ba389..3f5d5e0 100644
--- a/data.c
+++ b/data.c
@@ -631,42 +631,6 @@ int is_muted(snac *snac, char *actor)
}
-void enqueue_output(snac *snac, char *actor, char *msg, int retries)
-/* enqueues an output message for an actor */
-{
- if (strcmp(actor, snac->actor) == 0) {
- snac_debug(snac, 1, xs_str_new("enqueue refused to myself"));
- return;
- }
-
- int qrt = xs_number_get(xs_dict_get(srv_config, "query_retry_minutes"));
- xs *ntid = tid(retries * 60 * qrt);
- xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
- xs *tfn = xs_str_cat(fn, ".tmp");
- FILE *f;
-
- if ((f = fopen(tfn, "w")) != NULL) {
- xs *qmsg = xs_dict_new();
- xs *rn = xs_number_new(retries);
- xs *j;
-
- qmsg = xs_dict_append(qmsg, "type", "output");
- qmsg = xs_dict_append(qmsg, "actor", actor);
- qmsg = xs_dict_append(qmsg, "object", msg);
- qmsg = xs_dict_append(qmsg, "retries", rn);
-
- j = xs_json_dumps_pp(qmsg, 4);
-
- fwrite(j, strlen(j), 1, f);
- fclose(f);
-
- rename(tfn, fn);
-
- snac_debug(snac, 2, xs_fmt("enqueue %s %s %d", actor, fn, retries));
- }
-}
-
-
d_char *_actor_fn(snac *snac, char *actor)
/* returns the file name for an actor */
{
@@ -745,6 +709,42 @@ int actor_get(snac *snac, char *actor, d_char **data)
}
+void enqueue_output(snac *snac, char *actor, char *msg, int retries)
+/* enqueues an output message for an actor */
+{
+ if (strcmp(actor, snac->actor) == 0) {
+ snac_debug(snac, 1, xs_str_new("enqueue refused to myself"));
+ return;
+ }
+
+ int qrt = xs_number_get(xs_dict_get(srv_config, "query_retry_minutes"));
+ xs *ntid = tid(retries * 60 * qrt);
+ xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
+ xs *tfn = xs_str_cat(fn, ".tmp");
+ FILE *f;
+
+ if ((f = fopen(tfn, "w")) != NULL) {
+ xs *qmsg = xs_dict_new();
+ xs *rn = xs_number_new(retries);
+ xs *j;
+
+ qmsg = xs_dict_append(qmsg, "type", "output");
+ qmsg = xs_dict_append(qmsg, "actor", actor);
+ qmsg = xs_dict_append(qmsg, "object", msg);
+ qmsg = xs_dict_append(qmsg, "retries", rn);
+
+ j = xs_json_dumps_pp(qmsg, 4);
+
+ fwrite(j, strlen(j), 1, f);
+ fclose(f);
+
+ rename(tfn, fn);
+
+ snac_debug(snac, 2, xs_fmt("enqueue %s %s %d", actor, fn, retries));
+ }
+}
+
+
d_char *queue(snac *snac)
/* returns a list with filenames that can be dequeued */
{