diff options
| author | 2023-02-07 13:31:48 +0100 | |
|---|---|---|
| committer | 2023-02-07 13:31:48 +0100 | |
| commit | 4cca157641d5f91bde51baf437a3179e39d0b601 (patch) | |
| tree | 84e6cf02972ea3836fbd7e92f89d69f47ccd88b7 /data.c | |
| parent | Log unexpected q_item types. (diff) | |
| download | snac2-4cca157641d5f91bde51baf437a3179e39d0b601.tar.gz snac2-4cca157641d5f91bde51baf437a3179e39d0b601.tar.xz snac2-4cca157641d5f91bde51baf437a3179e39d0b601.zip | |
Output messages are now processed by the pool of threads.
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 30 |
1 files changed, 20 insertions, 10 deletions
| @@ -1373,25 +1373,35 @@ void enqueue_input(snac *snac, xs_dict *msg, xs_dict *req, int retries) | |||
| 1373 | } | 1373 | } |
| 1374 | 1374 | ||
| 1375 | 1375 | ||
| 1376 | void enqueue_output(snac *snac, xs_dict *msg, xs_str *inbox, int retries) | 1376 | void enqueue_output_raw(const char *keyid, const char *seckey, |
| 1377 | xs_dict *msg, xs_str *inbox, int retries) | ||
| 1377 | /* enqueues an output message to an inbox */ | 1378 | /* enqueues an output message to an inbox */ |
| 1378 | { | 1379 | { |
| 1379 | if (xs_startswith(inbox, snac->actor)) { | ||
| 1380 | snac_debug(snac, 1, xs_str_new("refusing enqueue to myself")); | ||
| 1381 | return; | ||
| 1382 | } | ||
| 1383 | |||
| 1384 | xs *qmsg = _new_qmsg("output", msg, retries); | 1380 | xs *qmsg = _new_qmsg("output", msg, retries); |
| 1385 | char *ntid = xs_dict_get(qmsg, "ntid"); | 1381 | char *ntid = xs_dict_get(qmsg, "ntid"); |
| 1386 | xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid); | 1382 | xs *fn = xs_fmt("%s/queue/%s.json", srv_basedir, ntid); |
| 1387 | 1383 | ||
| 1388 | qmsg = xs_dict_append(qmsg, "inbox", inbox); | 1384 | qmsg = xs_dict_append(qmsg, "inbox", inbox); |
| 1389 | qmsg = xs_dict_append(qmsg, "keyid", snac->actor); | 1385 | qmsg = xs_dict_append(qmsg, "keyid", keyid); |
| 1390 | qmsg = xs_dict_append(qmsg, "seckey", xs_dict_get(snac->key, "secret")); | 1386 | qmsg = xs_dict_append(qmsg, "seckey", seckey); |
| 1391 | 1387 | ||
| 1392 | qmsg = _enqueue_put(fn, qmsg); | 1388 | qmsg = _enqueue_put(fn, qmsg); |
| 1393 | 1389 | ||
| 1394 | snac_debug(snac, 1, xs_fmt("enqueue_output %s %s %d", inbox, fn, retries)); | 1390 | srv_debug(1, xs_fmt("enqueue_output %s %s %d", inbox, fn, retries)); |
| 1391 | } | ||
| 1392 | |||
| 1393 | |||
| 1394 | void enqueue_output(snac *snac, xs_dict *msg, xs_str *inbox, int retries) | ||
| 1395 | /* enqueues an output message to an inbox */ | ||
| 1396 | { | ||
| 1397 | if (xs_startswith(inbox, snac->actor)) { | ||
| 1398 | snac_debug(snac, 1, xs_str_new("refusing enqueue to myself")); | ||
| 1399 | return; | ||
| 1400 | } | ||
| 1401 | |||
| 1402 | char *seckey = xs_dict_get(snac->key, "secret"); | ||
| 1403 | |||
| 1404 | enqueue_output_raw(snac->actor, seckey, msg, inbox, retries); | ||
| 1395 | } | 1405 | } |
| 1396 | 1406 | ||
| 1397 | 1407 | ||