fix: preserve whatsapp group JIDs
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
- Group chat activation modes: per-group `/activation mention|always` command with status visibility.
|
- Group chat activation modes: per-group `/activation mention|always` command with status visibility.
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
- WhatsApp send now preserves existing JIDs (including group `@g.us`) instead of coercing to `@s.whatsapp.net`. (Thanks @arun-8687.)
|
||||||
- Telegram/WhatsApp: native replies now target the original inbound message; reply context is appended to `Body` and captured in `ReplyTo*` fields. (Thanks @joshp123 for the PR and follow-up question.)
|
- Telegram/WhatsApp: native replies now target the original inbound message; reply context is appended to `Body` and captured in `ReplyTo*` fields. (Thanks @joshp123 for the PR and follow-up question.)
|
||||||
- WhatsApp web creds persistence hardened; credentials are restored before auth checks and QR login auto-restarts if it stalls.
|
- WhatsApp web creds persistence hardened; credentials are restored before auth checks and QR login auto-restarts if it stalls.
|
||||||
- Canvas defaults/A2UI auto-nav aligned; debug status overlay centered; redundant await removed in `CanvasManager`.
|
- Canvas defaults/A2UI auto-nav aligned; debug status overlay centered; redundant await removed in `CanvasManager`.
|
||||||
|
|||||||
@@ -15,6 +15,12 @@ describe("toWhatsappJid", () => {
|
|||||||
it("converts E164 to jid", () => {
|
it("converts E164 to jid", () => {
|
||||||
expect(toWhatsappJid("+1 555 555 0123")).toBe("15555550123@s.whatsapp.net");
|
expect(toWhatsappJid("+1 555 555 0123")).toBe("15555550123@s.whatsapp.net");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("keeps group JIDs intact", () => {
|
||||||
|
expect(toWhatsappJid("123456789-987654321@g.us")).toBe(
|
||||||
|
"123456789-987654321@g.us",
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("assertProvider", () => {
|
describe("assertProvider", () => {
|
||||||
|
|||||||
@@ -69,6 +69,18 @@ describe("normalizeE164 & toWhatsappJid", () => {
|
|||||||
"5551234567@s.whatsapp.net",
|
"5551234567@s.whatsapp.net",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("preserves existing JIDs", () => {
|
||||||
|
expect(toWhatsappJid("123456789-987654321@g.us")).toBe(
|
||||||
|
"123456789-987654321@g.us",
|
||||||
|
);
|
||||||
|
expect(toWhatsappJid("whatsapp:123456789-987654321@g.us")).toBe(
|
||||||
|
"123456789-987654321@g.us",
|
||||||
|
);
|
||||||
|
expect(toWhatsappJid("1555123@s.whatsapp.net")).toBe(
|
||||||
|
"1555123@s.whatsapp.net",
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("jidToE164", () => {
|
describe("jidToE164", () => {
|
||||||
|
|||||||
@@ -54,7 +54,9 @@ export function isSelfChatMode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function toWhatsappJid(number: string): string {
|
export function toWhatsappJid(number: string): string {
|
||||||
const e164 = normalizeE164(number);
|
const withoutPrefix = number.replace(/^whatsapp:/, "").trim();
|
||||||
|
if (withoutPrefix.includes("@")) return withoutPrefix;
|
||||||
|
const e164 = normalizeE164(withoutPrefix);
|
||||||
const digits = e164.replace(/\D/g, "");
|
const digits = e164.replace(/\D/g, "");
|
||||||
return `${digits}@s.whatsapp.net`;
|
return `${digits}@s.whatsapp.net`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,12 @@ import { loadConfig } from "../config/config.js";
|
|||||||
import { isVerbose, logVerbose } from "../globals.js";
|
import { isVerbose, logVerbose } from "../globals.js";
|
||||||
import { createSubsystemLogger, getChildLogger } from "../logging.js";
|
import { createSubsystemLogger, getChildLogger } from "../logging.js";
|
||||||
import { saveMediaBuffer } from "../media/store.js";
|
import { saveMediaBuffer } from "../media/store.js";
|
||||||
import { isSelfChatMode, jidToE164, normalizeE164 } from "../utils.js";
|
import {
|
||||||
|
isSelfChatMode,
|
||||||
|
jidToE164,
|
||||||
|
normalizeE164,
|
||||||
|
toWhatsappJid,
|
||||||
|
} from "../utils.js";
|
||||||
import {
|
import {
|
||||||
createWaSocket,
|
createWaSocket,
|
||||||
getStatusCode,
|
getStatusCode,
|
||||||
@@ -336,7 +341,7 @@ export async function monitorWebInbox(options: {
|
|||||||
mediaBuffer?: Buffer,
|
mediaBuffer?: Buffer,
|
||||||
mediaType?: string,
|
mediaType?: string,
|
||||||
): Promise<{ messageId: string }> => {
|
): Promise<{ messageId: string }> => {
|
||||||
const jid = `${to.replace(/^\+/, "")}@s.whatsapp.net`;
|
const jid = toWhatsappJid(to);
|
||||||
let payload: AnyMessageContent;
|
let payload: AnyMessageContent;
|
||||||
if (mediaBuffer && mediaType) {
|
if (mediaBuffer && mediaType) {
|
||||||
if (mediaType.startsWith("image/")) {
|
if (mediaType.startsWith("image/")) {
|
||||||
@@ -376,7 +381,7 @@ export async function monitorWebInbox(options: {
|
|||||||
* Used after IPC send to show more messages are coming.
|
* Used after IPC send to show more messages are coming.
|
||||||
*/
|
*/
|
||||||
sendComposingTo: async (to: string): Promise<void> => {
|
sendComposingTo: async (to: string): Promise<void> => {
|
||||||
const jid = `${to.replace(/^\+/, "")}@s.whatsapp.net`;
|
const jid = toWhatsappJid(to);
|
||||||
await sock.sendPresenceUpdate("composing", jid);
|
await sock.sendPresenceUpdate("composing", jid);
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
Reference in New Issue
Block a user