@ccmsg/protocol 0.3.0 → 0.3.1
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/package.json
CHANGED
|
@@ -35,10 +35,13 @@ export const DIRECT_DELIVERY_FROM_MODE = "prompting";
|
|
|
35
35
|
/** How the recipient answers: the one line of instruction in the body.
|
|
36
36
|
*
|
|
37
37
|
* A command and not a description of one, because the recipient acts on it
|
|
38
|
-
* directly.
|
|
39
|
-
* so nothing has to be looked up to use it.
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
* directly. It carries both halves of the address — the sender to send to, and
|
|
39
|
+
* the frame being answered — so nothing has to be looked up to use it. A `mid`
|
|
40
|
+
* does not name its sender, and the alternative to spelling the sid out here
|
|
41
|
+
* would be an op that resolves one, which means a sent-message index the
|
|
42
|
+
* daemon does not otherwise need. */
|
|
43
|
+
export function directDeliveryReplyLine(mid: Mid, from: Sid): string {
|
|
44
|
+
return `Reply with: ccmsg reply ${mid} --to ${from} <text>`;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
/** An `InboxMessage` as it reaches a session through the messaging socket. */
|
|
@@ -94,7 +97,7 @@ export function renderDirectDelivery(message: InboxMessage): string {
|
|
|
94
97
|
if (message.reply_to !== undefined) {
|
|
95
98
|
attributes.push(`ccmsg-reply-to="${escapeAttribute(message.reply_to)}"`);
|
|
96
99
|
}
|
|
97
|
-
const body = `${message.text}\n\n${directDeliveryReplyLine(message.mid)}`;
|
|
100
|
+
const body = `${message.text}\n\n${directDeliveryReplyLine(message.mid, message.from)}`;
|
|
98
101
|
return `<${DIRECT_DELIVERY_TAG} ${attributes.join(" ")}>\n${body}\n</${DIRECT_DELIVERY_TAG}>`;
|
|
99
102
|
}
|
|
100
103
|
|
|
@@ -128,7 +131,7 @@ export function parseDirectDelivery(delivered: string): DirectDelivery | undefin
|
|
|
128
131
|
if (mid === undefined || from === undefined || from_label === undefined) return undefined;
|
|
129
132
|
|
|
130
133
|
let text = delivered.slice(opening[0].length, end);
|
|
131
|
-
const suffix = `\n\n${directDeliveryReplyLine(mid)}`;
|
|
134
|
+
const suffix = `\n\n${directDeliveryReplyLine(mid, from)}`;
|
|
132
135
|
if (text.endsWith(suffix)) text = text.slice(0, -suffix.length);
|
|
133
136
|
|
|
134
137
|
const reply_to = attributes.get("ccmsg-reply-to");
|