chore: format + regenerate protocol

This commit is contained in:
Peter Steinberger
2026-01-17 03:40:49 +00:00
parent 09bed2ccde
commit a82217a5f3
20 changed files with 79 additions and 74 deletions

View File

@@ -11,7 +11,9 @@ describe("formatInboundBodyWithSenderMeta", () => {
it("appends a sender meta line for non-direct messages", () => {
const ctx: MsgContext = { ChatType: "group", SenderName: "Alice", SenderId: "A1" };
expect(formatInboundBodyWithSenderMeta({ ctx, body: "[X] hi" })).toBe("[X] hi\n[from: Alice (A1)]");
expect(formatInboundBodyWithSenderMeta({ ctx, body: "[X] hi" })).toBe(
"[X] hi\n[from: Alice (A1)]",
);
});
it("prefers SenderE164 in the label when present", () => {
@@ -21,7 +23,9 @@ describe("formatInboundBodyWithSenderMeta", () => {
SenderId: "bob@s.whatsapp.net",
SenderE164: "+222",
};
expect(formatInboundBodyWithSenderMeta({ ctx, body: "[X] hi" })).toBe("[X] hi\n[from: Bob (+222)]");
expect(formatInboundBodyWithSenderMeta({ ctx, body: "[X] hi" })).toBe(
"[X] hi\n[from: Bob (+222)]",
);
});
it("preserves escaped newline style when body uses literal \\\\n", () => {
@@ -38,4 +42,3 @@ describe("formatInboundBodyWithSenderMeta", () => {
);
});
});

View File

@@ -1,9 +1,6 @@
import type { MsgContext } from "../templating.js";
export function formatInboundBodyWithSenderMeta(params: {
body: string;
ctx: MsgContext;
}): string {
export function formatInboundBodyWithSenderMeta(params: { body: string; ctx: MsgContext }): string {
const body = params.body;
if (!body.trim()) return body;
const chatType = params.ctx.ChatType?.trim().toLowerCase();

View File

@@ -49,4 +49,3 @@ describe("initSessionState sender meta", () => {
expect(result.sessionCtx.BodyStripped).toBe("[WhatsApp +1] ping");
});
});