Groups WIP #2
This commit is contained in:
parent
7be5cb1478
commit
a55e939592
4 changed files with 265 additions and 270 deletions
|
|
@ -58,7 +58,7 @@ const processMessage = async ({
|
|||
|
||||
const { attachments } = dataMessage;
|
||||
const rawTimestamp = dataMessage?.timestamp;
|
||||
|
||||
|
||||
// Debug logging for group detection
|
||||
console.log(`[fetch-signal-messages] Processing message:`, {
|
||||
sourceUuid,
|
||||
|
|
@ -77,22 +77,13 @@ const processMessage = async ({
|
|||
const formattedAttachments = await fetchAttachments(attachments);
|
||||
const primaryAttachment = formattedAttachments[0] ?? {};
|
||||
const additionalAttachments = formattedAttachments.slice(1);
|
||||
|
||||
// Extract group ID if this is a group message
|
||||
const groupId = dataMessage?.groupV2?.id || dataMessage?.groupContext?.id || dataMessage?.groupInfo?.groupId;
|
||||
|
||||
// IMPORTANT: Always use phoneNumber as 'to' for compatibility with Zammad
|
||||
// The group ID will be passed via the isGroup flag and potentially in metadata
|
||||
const toRecipient = phoneNumber;
|
||||
|
||||
console.log(`[fetch-signal-messages] Setting recipient:`, {
|
||||
isGroup,
|
||||
groupId,
|
||||
phoneNumber,
|
||||
toRecipient,
|
||||
note: 'Using phoneNumber as to for Zammad compatibility',
|
||||
});
|
||||
|
||||
|
||||
const groupId =
|
||||
dataMessage?.groupV2?.id ||
|
||||
dataMessage?.groupContext?.id ||
|
||||
dataMessage?.groupInfo?.groupId;
|
||||
const toRecipient = groupId ?? phoneNumber;
|
||||
|
||||
const primaryMessage = {
|
||||
token: id,
|
||||
to: toRecipient,
|
||||
|
|
@ -104,8 +95,6 @@ const processMessage = async ({
|
|||
filename: primaryAttachment.filename,
|
||||
mimeType: primaryAttachment.mimeType,
|
||||
isGroup,
|
||||
// Include groupId if this is a group message
|
||||
...(isGroup && groupId ? { groupId } : {}),
|
||||
};
|
||||
const formattedMessages = [primaryMessage];
|
||||
|
||||
|
|
@ -157,8 +146,10 @@ const fetchSignalMessagesTask = async ({
|
|||
number: phoneNumber,
|
||||
});
|
||||
|
||||
console.log(`[fetch-signal-messages] Fetching messages for bot ${id} (${phoneNumber})`);
|
||||
|
||||
console.log(
|
||||
`[fetch-signal-messages] Fetching messages for bot ${id} (${phoneNumber})`,
|
||||
);
|
||||
|
||||
for (const message of messages) {
|
||||
const formattedMessages = await processMessage({
|
||||
id,
|
||||
|
|
@ -175,7 +166,7 @@ const fetchSignalMessagesTask = async ({
|
|||
hasMessage: !!formattedMessage.message,
|
||||
hasAttachment: !!formattedMessage.attachment,
|
||||
});
|
||||
|
||||
|
||||
await worker.addJob(
|
||||
"signal/receive-signal-message",
|
||||
formattedMessage,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue