mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 17:45:04 +00:00
New function enqueue_message().
This commit is contained in:
parent
286eb291c7
commit
427f7341fa
3 changed files with 29 additions and 0 deletions
|
@ -990,6 +990,17 @@ void process_queue(snac *snac)
|
|||
if ((type = xs_dict_get(q_item, "type")) == NULL)
|
||||
type = "output";
|
||||
|
||||
if (strcmp(type, "message") == 0) {
|
||||
char *msg = xs_dict_get(q_item, "message");
|
||||
xs *inboxes = inbox_list(snac, msg);
|
||||
char *p, *v;
|
||||
|
||||
p = inboxes;
|
||||
while (xs_list_iter(&p, &v)) {
|
||||
enqueue_output(snac, msg, v, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (strcmp(type, "output") == 0) {
|
||||
int status;
|
||||
char *inbox = xs_dict_get(q_item, "inbox");
|
||||
|
|
17
data.c
17
data.c
|
@ -1384,6 +1384,23 @@ void enqueue_email(snac *snac, char *msg, int retries)
|
|||
}
|
||||
|
||||
|
||||
void enqueue_message(snac *snac, char *msg)
|
||||
/* enqueues an output message */
|
||||
{
|
||||
char *id = xs_dict_get(msg, "id");
|
||||
xs *ntid = tid(0);
|
||||
xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
|
||||
xs *qmsg = xs_dict_new();
|
||||
|
||||
qmsg = xs_dict_append(qmsg, "type", "message");
|
||||
qmsg = xs_dict_append(qmsg, "message", msg);
|
||||
|
||||
_enqueue_put(fn, qmsg);
|
||||
|
||||
snac_debug(snac, 1, xs_fmt("enqueue_message %s", id));
|
||||
}
|
||||
|
||||
|
||||
d_char *queue(snac *snac)
|
||||
/* returns a list with filenames that can be dequeued */
|
||||
{
|
||||
|
|
1
snac.h
1
snac.h
|
@ -127,6 +127,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_by_actor(snac *snac, char *msg, char *actor, int retries);
|
||||
void enqueue_email(snac *snac, char *msg, int retries);
|
||||
void enqueue_message(snac *snac, char *msg);
|
||||
|
||||
d_char *queue(snac *snac);
|
||||
d_char *dequeue(snac *snac, char *fn);
|
||||
|
|
Loading…
Reference in a new issue