mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-16 21:10:47 +08:00
Revert "Fix WhatsApp connection test delivery without touching DSH sessions."
This reverts commit 0bc0992330.
This commit is contained in:
parent
0bc0992330
commit
dd2365407e
5 changed files with 206 additions and 396 deletions
|
|
@ -9,19 +9,11 @@ import {
|
|||
|
||||
import { emptyAccessGrant, ensureGroupBucket, normalizeAccessPhone, phoneFromWhatsappJid, resolveAccessAgentPreset } from '../shared/access-grant.mjs';
|
||||
import { splitMessageText } from '../shared/editable-message-stream.mjs';
|
||||
import {
|
||||
connectionTestTarget,
|
||||
} from '../shared/connection-test.mjs';
|
||||
import { t } from '../shared/i18n.mjs';
|
||||
import { ImagePromptError } from '../shared/image-prompt.mjs';
|
||||
import { trackOutboundArtifactProviderPromise } from '../shared/semantic/artifact.mjs';
|
||||
import { createWhatsappBridgeStatus, WhatsappHarnessBridge } from './whatsapp-bridge.mjs';
|
||||
import {
|
||||
enrichWhatsappInboundIdentities,
|
||||
resolveWhatsappGroupSubject,
|
||||
resolveWhatsappGroupSubjects,
|
||||
resolveWhatsappSelfChatJid,
|
||||
} from './whatsapp-identity.mjs';
|
||||
import { enrichWhatsappInboundIdentities, resolveWhatsappGroupSubject, resolveWhatsappGroupSubjects } from './whatsapp-identity.mjs';
|
||||
import {
|
||||
gateWhatsappInbound,
|
||||
loadWhatsappAccessGrant,
|
||||
|
|
@ -873,10 +865,6 @@ export class WhatsappRuntime {
|
|||
return this.stop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Channel-direct probe (no Harness / DSH session). Prefer the last bound
|
||||
* private-chat reply target; otherwise Message Yourself via live LID/PN.
|
||||
*/
|
||||
async sendConnectionTest(text) {
|
||||
if (!this.#status.ready || !this.#client) {
|
||||
const error = new Error(t('WhatsApp机器人尚未连接'));
|
||||
|
|
@ -886,34 +874,13 @@ export class WhatsappRuntime {
|
|||
if (typeof text !== 'string' || !text.trim()) {
|
||||
throw new TypeError('WhatsApp connection test text is required');
|
||||
}
|
||||
const target = await this.#connectionTestSendTarget();
|
||||
await this.#client.sendText(target, text);
|
||||
await this.#client.sendText({
|
||||
jid: this.#config.accountJid,
|
||||
selfChat: true,
|
||||
}, text);
|
||||
return { sent: true };
|
||||
}
|
||||
|
||||
async #connectionTestSendTarget() {
|
||||
const remembered = connectionTestTarget(this.#state);
|
||||
const rememberedJid = typeof remembered?.jid === 'string' ? remembered.jid.trim() : '';
|
||||
if (rememberedJid) {
|
||||
let selfChat = remembered.selfChat === true;
|
||||
if (!selfChat) {
|
||||
try {
|
||||
selfChat = areJidsSameUser(rememberedJid, this.#config.accountJid) === true;
|
||||
} catch {
|
||||
selfChat = false;
|
||||
}
|
||||
}
|
||||
// Bound chat only — drop quoted/key so this is a fresh probe, not a reply.
|
||||
return { jid: rememberedJid, selfChat };
|
||||
}
|
||||
const jid = await resolveWhatsappSelfChatJid({
|
||||
socket: this.#session?.socket,
|
||||
accountJid: this.#config.accountJid,
|
||||
lidPnCache: this.#lidPnCache,
|
||||
});
|
||||
return { jid, selfChat: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync WhatsApp group subjects into accessGrant.groups[*].title.
|
||||
* @param {string[]|null|undefined} groupJids
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue