mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-25 05:52:34 +00:00
feat(whatsapp): surface quoted reply metadata
This commit is contained in:
parent
fd9c1504da
commit
bd33a48a58
2 changed files with 46 additions and 1 deletions
|
|
@ -300,7 +300,10 @@ async function startSocket() {
|
||||||
const messageContent = getMessageContent(msg);
|
const messageContent = getMessageContent(msg);
|
||||||
const contextInfo = getContextInfo(messageContent);
|
const contextInfo = getContextInfo(messageContent);
|
||||||
const mentionedIds = Array.from(new Set((contextInfo?.mentionedJid || []).map(normalizeWhatsAppId).filter(Boolean)));
|
const mentionedIds = Array.from(new Set((contextInfo?.mentionedJid || []).map(normalizeWhatsAppId).filter(Boolean)));
|
||||||
const quotedParticipant = normalizeWhatsAppId(contextInfo?.participant || contextInfo?.remoteJid || '');
|
const quotedMessageId = contextInfo?.stanzaId || null;
|
||||||
|
const quotedParticipant = normalizeWhatsAppId(contextInfo?.participant || '') || null;
|
||||||
|
const quotedRemoteJid = normalizeWhatsAppId(contextInfo?.remoteJid || '') || null;
|
||||||
|
const hasQuotedMessage = !!contextInfo?.quotedMessage;
|
||||||
|
|
||||||
// Extract message body
|
// Extract message body
|
||||||
let body = '';
|
let body = '';
|
||||||
|
|
@ -412,7 +415,10 @@ async function startSocket() {
|
||||||
mediaType,
|
mediaType,
|
||||||
mediaUrls,
|
mediaUrls,
|
||||||
mentionedIds,
|
mentionedIds,
|
||||||
|
quotedMessageId,
|
||||||
quotedParticipant,
|
quotedParticipant,
|
||||||
|
quotedRemoteJid,
|
||||||
|
hasQuotedMessage,
|
||||||
botIds,
|
botIds,
|
||||||
timestamp: msg.messageTimestamp,
|
timestamp: msg.messageTimestamp,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,10 @@ def _make_adapter():
|
||||||
adapter._message_queue = asyncio.Queue()
|
adapter._message_queue = asyncio.Queue()
|
||||||
adapter._http_session = MagicMock()
|
adapter._http_session = MagicMock()
|
||||||
adapter._mention_patterns = []
|
adapter._mention_patterns = []
|
||||||
|
adapter._dm_policy = "open"
|
||||||
|
adapter._allow_from = set()
|
||||||
|
adapter._group_policy = "open"
|
||||||
|
adapter._group_allow_from = set()
|
||||||
return adapter
|
return adapter
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -287,6 +291,41 @@ class TestSendChunking:
|
||||||
assert "Not connected" in result.error
|
assert "Not connected" in result.error
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# bridge event metadata
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestBridgeEventMetadata:
|
||||||
|
"""WhatsApp bridge metadata is preserved for downstream consumers."""
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_quoted_reply_metadata_is_preserved_in_raw_message(self):
|
||||||
|
adapter = _make_adapter()
|
||||||
|
data = {
|
||||||
|
"messageId": "incoming-msg",
|
||||||
|
"chatId": "15551234567@s.whatsapp.net",
|
||||||
|
"senderId": "15551234567@s.whatsapp.net",
|
||||||
|
"senderName": "Tester",
|
||||||
|
"chatName": "Tester",
|
||||||
|
"isGroup": False,
|
||||||
|
"body": "approved",
|
||||||
|
"hasMedia": False,
|
||||||
|
"mediaUrls": [],
|
||||||
|
"quotedMessageId": "outbound-msg",
|
||||||
|
"quotedParticipant": "99999999999@s.whatsapp.net",
|
||||||
|
"quotedRemoteJid": "15551234567@s.whatsapp.net",
|
||||||
|
"hasQuotedMessage": True,
|
||||||
|
}
|
||||||
|
|
||||||
|
event = await adapter._build_message_event(data)
|
||||||
|
|
||||||
|
assert event is not None
|
||||||
|
assert event.raw_message["quotedMessageId"] == "outbound-msg"
|
||||||
|
assert event.raw_message["quotedParticipant"] == "99999999999@s.whatsapp.net"
|
||||||
|
assert event.raw_message["quotedRemoteJid"] == "15551234567@s.whatsapp.net"
|
||||||
|
assert event.raw_message["hasQuotedMessage"] is True
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# display_config tier classification
|
# display_config tier classification
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue