edge-book 0.18.1 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/edge-book.js +14 -1
- package/package.json +1 -1
package/dist/edge-book.js
CHANGED
|
@@ -7265,10 +7265,23 @@ next: ${result.next_action}`, json: result };
|
|
|
7265
7265
|
const action = args.shift();
|
|
7266
7266
|
if (action === "send") {
|
|
7267
7267
|
const deliver = takeBoolFlag(args, "--deliver");
|
|
7268
|
+
const hostUrl = parseHost(args, ctx);
|
|
7268
7269
|
const peer = requireArg(args.shift(), "peer-agent-id");
|
|
7269
7270
|
const body = requireArg(takeFlag(args, "--body"), "--body");
|
|
7270
7271
|
const envelope = await store.sendPrivilegedMessage(peer, { text: body });
|
|
7271
|
-
if (deliver)
|
|
7272
|
+
if (deliver) {
|
|
7273
|
+
try {
|
|
7274
|
+
return { text: await deliverToPeer(store, envelope, peer), json: envelope };
|
|
7275
|
+
} catch (err) {
|
|
7276
|
+
if (!(err instanceof EdgeBookError) || err.code !== "no_route") throw err;
|
|
7277
|
+
const outcome = await deliverViaMailboxRecorded(
|
|
7278
|
+
envelope,
|
|
7279
|
+
{ home, host: hostUrl, socketFactory: ctx.socketFactory },
|
|
7280
|
+
(id) => `Sent message to ${peer} over the mailbox (host id ${id})`
|
|
7281
|
+
);
|
|
7282
|
+
return { text: outcome.text, json: envelope };
|
|
7283
|
+
}
|
|
7284
|
+
}
|
|
7272
7285
|
return { text: JSON.stringify(envelope, null, 2), json: envelope };
|
|
7273
7286
|
}
|
|
7274
7287
|
if (action === "receive") {
|