mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
Reworked enqueue_output().
This commit is contained in:
parent
0233d73248
commit
4e62b409af
2 changed files with 8 additions and 13 deletions
13
data.c
13
data.c
|
@ -1336,7 +1336,7 @@ static xs_dict *_new_qmsg(const char *type, const xs_dict *msg, int retries)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void enqueue_input(snac *snac, char *msg, char *req, int retries)
|
void enqueue_input(snac *snac, xs_dict *msg, xs_dict *req, int retries)
|
||||||
/* enqueues an input message */
|
/* enqueues an input message */
|
||||||
{
|
{
|
||||||
xs *qmsg = _new_qmsg("input", msg, retries);
|
xs *qmsg = _new_qmsg("input", msg, retries);
|
||||||
|
@ -1351,7 +1351,7 @@ void enqueue_input(snac *snac, char *msg, char *req, int retries)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void enqueue_output(snac *snac, char *msg, char *inbox, int retries)
|
void enqueue_output(snac *snac, xs_dict *msg, xs_str *inbox, int retries)
|
||||||
/* enqueues an output message to an inbox */
|
/* enqueues an output message to an inbox */
|
||||||
{
|
{
|
||||||
if (xs_startswith(inbox, snac->actor)) {
|
if (xs_startswith(inbox, snac->actor)) {
|
||||||
|
@ -1359,16 +1359,11 @@ void enqueue_output(snac *snac, char *msg, char *inbox, int retries)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qrt = xs_number_get(xs_dict_get(srv_config, "queue_retry_minutes"));
|
xs *qmsg = _new_qmsg("output", msg, retries);
|
||||||
xs *ntid = tid(retries * 60 * qrt);
|
char *ntid = xs_dict_get(qmsg, "ntid");
|
||||||
xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
|
xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
|
||||||
xs *qmsg = xs_dict_new();
|
|
||||||
xs *rn = xs_number_new(retries);
|
|
||||||
|
|
||||||
qmsg = xs_dict_append(qmsg, "type", "output");
|
|
||||||
qmsg = xs_dict_append(qmsg, "inbox", inbox);
|
qmsg = xs_dict_append(qmsg, "inbox", inbox);
|
||||||
qmsg = xs_dict_append(qmsg, "message", msg);
|
|
||||||
qmsg = xs_dict_append(qmsg, "retries", rn);
|
|
||||||
|
|
||||||
qmsg = _enqueue_put(fn, qmsg);
|
qmsg = _enqueue_put(fn, qmsg);
|
||||||
|
|
||||||
|
|
4
snac.h
4
snac.h
|
@ -121,8 +121,8 @@ d_char *history_get(snac *snac, char *id);
|
||||||
int history_del(snac *snac, char *id);
|
int history_del(snac *snac, char *id);
|
||||||
d_char *history_list(snac *snac);
|
d_char *history_list(snac *snac);
|
||||||
|
|
||||||
void enqueue_input(snac *snac, char *msg, char *req, int retries);
|
void enqueue_input(snac *snac, xs_dict *msg, xs_dict *req, int retries);
|
||||||
void enqueue_output(snac *snac, char *msg, char *inbox, int retries);
|
void enqueue_output(snac *snac, xs_dict *msg, xs_str *inbox, int retries);
|
||||||
void enqueue_output_by_actor(snac *snac, char *msg, char *actor, int retries);
|
void enqueue_output_by_actor(snac *snac, char *msg, char *actor, int retries);
|
||||||
void enqueue_email(snac *snac, char *msg, int retries);
|
void enqueue_email(snac *snac, char *msg, int retries);
|
||||||
void enqueue_message(snac *snac, char *msg);
|
void enqueue_message(snac *snac, char *msg);
|
||||||
|
|
Loading…
Reference in a new issue