iachat/spec/services
Gabriel Coelho d2a0d53fab
feat(whatsapp): get contact profile picture when using Baileys service (#98)
* feat(whatsapp): add profile picture fetching for Baileys provider

- Add `get_profile_pic` method to `WhatsappBaileysService` for fetching contact avatars
- Include `avatar_url` in contact attributes during contact creation
- Update `MessagesUpsert` handler to fetch and set profile pictures
- Add proper error handling and graceful degradation when avatar fetching fails

* test(whatsapp): add test coverage for Baileys profile picture fetching

- Add test suite for `get_profile_pic` method
- Include test scenarios for successful responses, missing avatars, and error handling
- Add profile picture HTTP stubbing and avatar job expectations to message processing tests

* feat(whatsapp): optimize Baileys avatar fetching and update avatar for existing inboxes

Previously, the profile picture was fetched on every incoming message and avatar updates were only attempted for new inboxes.

This change optimizes the process by:
- Only fetching the WhatsApp profile picture if the contact does not already have an avatar.
- Attempting to update the avatar for both new and existing inboxes.

This logic is based on Telegram's version (app/services/telegram/incoming_message_service.rb).

* refactor(whatsapp): remove unnecessary safe navigation when accessing contact

This reverts an unnecessary change introduced in b918a92.

* refactor(whatsapp): manually rollback change introduced in b918a92

* refactor(whatsapp): rename endpoint to profile-picture-url

* refactor(whatsapp): simplify profile picture response handling

Replaced manual JSON parsing with HTTParty's parsed_response and removed redundant JSON parsing tests.

* test(whatsapp): separate avatar processing test from message creation test

* test(whatsapp): update profile picture test to match actual API behavior

Change test to expect a 404 response when no profile picture exists, instead of a 200 response with partial data.

* refactor: move new functions to helper module

* test: more specs

---------

Co-authored-by: gabrieljablonski <contact@gabrieljablonski.com>
2025-08-27 13:02:04 -03:00
..
account fix: account email validation during signup (#11307) 2025-05-20 20:45:39 -07:00
auto_assignment chore: Enable the new Rubocop rules (#7122) 2023-05-19 14:37:10 +05:30
automation_rules Merge branch 'main' into chatwoot/develop 2025-07-16 09:37:08 -03:00
contacts chore: apply Rails/SaveBang cop (#15) 2025-04-03 23:29:24 -03:00
conversations Merge branch 'main' into chore/merge-upstream 2025-05-30 11:03:07 -03:00
crm/leadsquared Merge branch 'main' into chore/merge-upstream 2025-05-30 11:03:07 -03:00
facebook feat: Add message support for input_select type in Facebook (#11627) 2025-06-10 16:15:11 +05:30
google chore: apply Rails/SaveBang cop (#15) 2025-04-03 23:29:24 -03:00
imap feat: Add configurable interval for IMAP sync (#9302) 2024-04-25 18:58:20 -07:00
instagram feat: Handle instagram test service (#11244) 2025-04-11 19:11:29 +05:30
internal feat: add job to remove stale contacts and contact_inboxes (#11186) 2025-03-28 12:18:39 +05:30
labels fix: Update associations when a label is updated (#3046) 2021-09-21 10:16:32 +05:30
line fix: input_select styles in Line channel (#11805) 2025-07-02 12:33:29 +05:30
linear feat: Whatsapp embedded signup (#11612) 2025-07-14 21:37:06 -07:00
liquid feat: Add liquid processing for SMS campaigns (#10981) 2025-06-11 13:16:44 -04:00
llm_formatter Merge branch 'main' into chatwoot/develop 2025-07-16 09:37:08 -03:00
macros feat: Add webhook event support for macros (#11235) 2025-04-02 20:26:55 -07:00
message_templates Merge branch 'main' into chore/merge-upstream-4.5.0 2025-08-20 11:20:31 -03:00
messages feat: Add the ability to mention team in private message (#11758) 2025-07-02 19:57:59 +05:30
microsoft chore: apply Rails/SaveBang cop (#15) 2025-04-03 23:29:24 -03:00
notification chore: Disable email notifications for unconfirmed users (#10964) 2025-02-24 12:14:40 -08:00
sms Merge branch 'main' into chore/merge-upstream-4.5.0 2025-08-20 11:20:31 -03:00
telegram feat(channel): add support for Telegram Business bots (#10181) (#11663) 2025-06-16 20:35:23 -07:00
twilio chore: fix spec 2025-08-20 12:08:01 -03:00
twitter chore: Enable the new Rubocop rules (#7122) 2023-05-19 14:37:10 +05:30
whatsapp feat(whatsapp): get contact profile picture when using Baileys service (#98) 2025-08-27 13:02:04 -03:00
account_deletion_service_spec.rb feat: automate account deletion (#11406) 2025-05-23 12:58:13 +05:30
action_service_spec.rb chore: Add open conversation option (#11828) 2025-07-02 10:01:50 +05:30
csat_survey_service_spec.rb Merge branch 'main' into chatwoot/develop 2025-07-16 09:37:08 -03:00
search_service_spec.rb Merge branch 'main' into chore/merge-upstream-4.5.0 2025-08-20 11:20:31 -03:00