chatwoot / chatwoot/utils

getRecipients drops incoming email To recipients from the reply CC

Open Beginner friendly
#67 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11
Forks
13
PR merge metrics
No merged PRs in 30d

Description

`getRecipients` builds the reply recipients from the last email in a conversation. For an incoming email, it is expected to move extra `To` recipients into the reply `cc` (minus the inbox address). It does not. The incoming branch hardcodes the To list to empty:

```ts
if (isIncoming) {
...
emailAttributes = {
cc: email?.cc || [],
bcc: email?.bcc || [],
from: email?.from || [],
to: [], // <-- drops the email's actual To recipients
};
}
```

So this later step is always a no-op for incoming emails:

```ts
// Only include 'to' recipients in cc for incoming emails, not for outgoing
if (Array.isArray(emailAttributes.to) && isIncoming) {
cc.push(...emailAttributes.to);
}
```

**Effect in Chatwoot:** a customer sends an email to the inbox with a colleague in the To line (not CC). The agent replies from the dashboard. The reply box computes an empty CC and the colleague silently falls off the thread.

**Repro:**

```ts
getRecipients(
incomingEmail({ from: ['customer@example.com'], to: ['inbox@co.com', 'colleague@example.com'] }),
'customer@example.com',
'inbox@co.com',
''
);
// actual: cc = []
// expected: cc = ['colleague@example.com']
```

**Regression:** before #43 the function read the raw email object, so `emailAttributes.to` held the real To list and the `cc.push` worked. #43 restructured the branches and zeroed `to` for incoming; #50 kept the guard but the array is always empty. There is no test covering an incoming email with extra To recipients — the `createIncomingEmail` fixture has no `to` field at all.

Fix incoming: pass `email?.to || []` so the existing cc-building step and filters work again.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at getRecipients and inspect the incoming branch where emailAttributes.to is assigned. Update the incoming email handling and extend the createIncomingEmail fixture or its tests with an inbox address and an extra To recipient; done means the colleague appears in the reply CC while the inbox address is filtered out.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.