Commit Graph

5 Commits

Author SHA1 Message Date
Petterson
9d808a18df
fix(drops): Resolve first_name for single-word contact and agent names (#13488)
WhatsApp template variables like `{{contact.first_name}}` previously
resolved to an empty string whenever a contact or agent had a
single-word name (e.g. "Petterson"). Because the variable came back
blank, WhatsApp template sends would either fail validation or get stuck
indefinitely in the "Sending" state. With this fix, `first_name` falls
back to the full single-word name, so templates render correctly for
everyone regardless of how many words their name has.

## Closes

- Fixes #13222

## How to reproduce

1. Create a contact with a single-word name (e.g. `Petterson`).
2. Configure a WhatsApp template action that uses
`{{contact.first_name}}`.
3. Send the template message.
4. **Before:** the variable resolves to an empty string and the message
fails / stays in "Sending".
**After:** the variable resolves to `Petterson` and the message sends.

## What changed

- Removed the "name must have 2+ words" guard from `first_name` in
`ContactDrop` and `UserDrop`, so a single-word name is returned (still
capitalized).
- Capitalization behavior introduced in #6758 is preserved; only the
single-word edge case changes.
- `last_name` still returns `nil` for single-word names, which is the
expected behavior.
- Added specs covering single-word names for both `ContactDrop` and
`UserDrop`.

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Muhsin <12408980+muhsin-k@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-05 10:03:24 +04:00
Sojan Jose
7ab7bac6bf
chore: Enable the new Rubocop rules (#7122)
fixes: https://linear.app/chatwoot/issue/CW-1574/renable-the-disabled-rubocop-rules
2023-05-19 14:37:10 +05:30
Muhsin Keloth
3535a1a708
chore: Auto capitalize the last name field while sending the canned response/variables (#6767)
* Capitalize last name

* Add more spec

* Fix last name spec issue

* More spec fixes

* Add more spec fixes

* Update user_drop_spec.rb
2023-03-28 13:03:51 +05:30
Muhsin Keloth
5b7bed9640
chore: Auto capitalize the name field while sending the canned response/variables (#6758)
* capitalize name before sending the message

* Fix specs

* Code cleanups
2023-03-27 18:49:48 +05:30
Muhsin Keloth
078ff615ee
feat: Add support for template variables in messages content (#6215)
Fixes: #6078

Co-authored-by: Sojan <sojan@pepalo.com>
2023-01-10 16:00:34 +05:30