Commit Graph

1005 Commits

Author SHA1 Message Date
Sojan Jose
d10525a714 fix: Template sync issue for older Whatsapp channels (#8830)
- This PR introduces a modification to the channel fetching logic, ensuring that channels with older message_template_last_updated timestamps are prioritized during synchronization.
2024-01-31 18:38:01 +04:00
Sojan Jose
390cd756e8 chore: Reorganize the installation config settings (#8794)
- Reorganizing installation config settings to move more configurations into UI from environment variables
- Changes to installation config to support premium plans in the enterprise edition
- Fixes the broken premium indicator in account/show and accounts/edit page
2024-01-31 16:48:42 +04:00
Pranav Raj S
ee3f734b7b chore: Refactor RefreshOauthTokenService to improve readability (#8820)
- Added a trait called microsoft_email for the Channel::Email factory.
- Rewrote the logic to make it simple to understand
- Rewrote the specs for readability
2024-01-31 12:24:12 +04:00
Pranav Raj S
905ca94f71 chore: Remove unused attribute imap_inbox_synced_at (#8822)
- imap_inbox_synced_at is no longer used; this PR removes all the references to the same.
2024-01-31 11:48:46 +04:00
Sojan Jose
0805f362d3 chore: Validation for purchased pricing_plan_quantity (#8809)
- Add validations based on purchased pricing_plan_quantity
- Modify the Dashboard to support the new error message
2024-01-30 11:26:07 +04:00
Sojan Jose
648c4caca1 chore: Move EE OpenAI spec to correct folder (#8805)
- We previously had this spec inside the enterprise folder which wouldn't be picked up by our build process, so moving to the correct folder instead.

Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
2024-01-29 20:09:17 +04:00
Muhsin Keloth
ef50edb9e2 feat: Standardise the external channel user id and user name (#8802)
* feat: Standardize the external channel id and user name

* chore: add specs

* chore: add name space `social`
2024-01-29 16:57:10 +05:30
Shivam Mishra
3ed80fa867 feat: expiry for cache keys [CW-3038] (#8793)
* feat: set cache keys for 3 days only

* feat: invalidate should set the latest timestamp

* refactor: cache_keys concern

* remove invalidate_cache method
* refactor reset to set to new value instead of delete
* ensure only one event is dispatched

* feat: set expiry to 24 hours

* chore: make expiry 48 hours

* feat: include destroy event

* feat: set expiry to 72 days

* fix: typo

* test: cache update after `touch`

* test: update cache keys

* refactor: remove after_touch, it's already handled in commit
2024-01-29 15:27:26 +05:30
Shivam Mishra
082793290a feat: allow multiple files for FB and Insta [CW-3019] (#8783)
* feat: allow multiple messages

* fix: typo

* feat: send content and attachments both

* refactor: message sequence

* test: multiple attachments for instagram

* test: multiple attachments on facebook
2024-01-28 13:20:54 +05:30
Pranav Raj S
12916ceca6 fix: Capture delivery errors to avoid false positives (#8790)
The system did not detect the delivery errors earlier, resulting in some false positives. The user was not informed when an email failed to be delivered. While we do handle failure status in other channels, we were not able to capture the actual delivery status for the email channel.

This pull request makes the following changes:

- Updated the class EmailReplyWorker to use the deliver_now method instead of deliver_later. This change is made to raise any errors that may occur with the SMTP connection. The errors are then captured and sent to Sentry, and the email is marked as failed. Previously, we did not consider the case of retries in the email channel, so this feature is currently not functioning. So, I have disabled the retry option. We will address this in a follow-up ticket.
- Downgraded the net-smtp gem to version 0.3.4. This change is made to avoid an argument error when using XOAUTH2.

Fixes: https://linear.app/chatwoot/issue/CW-3032/argumenterror-wrong-authentication-type-xoauth2-argumenterror
2024-01-26 14:22:18 +04:00
Pranav Raj S
b7c9f779ad fix: Avoid processing reactions, ephemeral, request_welcome or unsupported messages (#8780)
Currently, we do not support reactions, ephemeral messages, or the request_welcome event for the WhatsApp channel. However, if this is the first event we receive in Chatwoot (i.e., there is no previous conversation or contact in Chatwoot), it will create a contact and a conversation without any messages. This confuses our customer, as it may appear that Chatwoot has missed some messages. There are multiple cases where this might be the first event we receive in Chatwoot. One quick example is when the user has sent an outbound campaign from another tool and their customers reacted to the message.

Another event like this is request_welcome event. WhatsApp has a concept for welcome messages. You can send an outbound message even though the user has not send a message. You can receive notifications through a webhook whenever a WhatsApp user initiates a chat with you for the first time. (Read the Welcome message section: https://developers.facebook.com/docs/whatsapp/cloud-api/phone-numbers/conversational-components/ ). Although this can help the business send a pro-active message to the user, we don't have it scoped in our feature set. For now, I'm ignoring this event.

Fixes https://linear.app/chatwoot/issue/CW-3018/whatsapp-handle-request-welcome-case-properly
Fixes https://linear.app/chatwoot/issue/CW-3017/whatsapp-handle-reactions-properly
2024-01-25 11:40:18 +04:00
Shivam Mishra
3760f206e8 fix: mutex timeout and error handling (#8770)
Fixes the follow cases 
- The ensure block released the lock even on LockAcquisitionError
- Custom timeout was not allowed

This also refactored the with_lock method, now the key has to be constructed in the parent function itself

Co-authored-by: Sojan Jose <sojan@pepalo.com>
2024-01-24 14:18:21 +04:00
Sojan Jose
a861257f73 chore: Fix flaky contacts spec (#8773)
- The ordering was not guaranteed; hence, the specs were failing randomly. Made changes to the expectations accordingly
2024-01-24 13:58:27 +04:00
Vishnu Narayanan
232369cd5c feat: sla 1 - refactor sla_policies model and add applied_sla model (#8602)
* feat: add models

* chore: refactor sla column names

* chore: remove foreign keys

* chore: fix spec

* chore: refactor models
2024-01-23 23:48:02 +05:30
Surabhi Suman
4b40c61201 feat: Support Regex validation for custom attributes (#7856)
This allows a user to add/update a custom regex and a cue while defining custom attributes(Only applicable for type- text).
While adding/editing custom attributes, the values are validated against the attribute definition regex, and if it is incorrect, a cue message or default error message is shown and restricts invalid values from being saved.

Fixes: #6866
2024-01-23 18:01:57 +04:00
Shivam Mishra
834c219b9b feat(perf): update query to do a simpler search [CW-2997] (#8763)
Message search would frequently timeout. The reason was that the query would join the conversation too, the new query searches the message table directly

Co-authored-by: Sojan <sojan@pepalo.com>
2024-01-23 14:20:00 +04:00
Shivam Mishra
1dc66db516 fix: SQL error when rules with missing attributes is triggered (#8673) 2024-01-22 16:09:34 +05:30
Pranav Raj S
a8f053921b fix: Migrate notes when merging the contacts (#8749)
Fixes: https://linear.app/chatwoot/issue/CW-2987/migrate-notes-of-the-secondary-contact-to-primary-contact-when-merging
2024-01-20 10:32:18 +04:00
Pranav Raj S
29106ebc4b fix: raise_lock_acquisition_error if the job cannot set the lock (#8744)
Consider a scenario where two jobs are concurrently accessing a job with a lock mechanism. If the second job accesses lock_manager.locked? before the first job called lock_manager.lock(lock_key), it would return a false positive. At this point, both jobs can be executed freely.

To address this issue, the following change ensures that only the current thread that has set the lock can execute. Otherwise, a LockAcquisitionError will be thrown.

Co-authored-by: Sojan Jose <sojan@pepalo.com>
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
2024-01-19 14:31:41 +04:00
Muhsin Keloth
0ac015ce7a feat: Add a job to clear notifications that were created before 1 month (#8732) 2024-01-19 13:03:23 +05:30
Sojan Jose
ce8190dacf fix: API error when using SuperAdmin token (#8739)
- Fixes the issue in release 3.5.0, which causes SuperAdmin tokens to throw error during API calls

Fixes: #8719
2024-01-18 18:49:32 +04:00
Shivam Mishra
e39c14460b fix: validate url for Dashboard Apps [CW-2979] (#8736) 2024-01-18 17:48:30 +05:30
Sojan Jose
5f6e17f307 feat: Use Telegram HTML Parsemode (#8731)
- this ensures that the markdown formatted messages from the Chatwoot dashboard will render consistently in telegram UI for the supported types like bold, italics, links etc
2024-01-18 15:36:36 +04:00
Muhsin Keloth
c899cc825d fix: Handle Contact import MalformedCSVError (#8706) 2024-01-18 13:05:58 +05:30
Sojan Jose
76fe2f9bb8 chore: Switch to Markdown instead of MarkdownV2 for telegram channel (#8720) 2024-01-17 14:28:13 +05:30
Muhsin Keloth
818424259f chore: Get all notification API improvments (#8549)
Co-authored-by: Sojan Jose <sojan@chatwoot.com>
2024-01-17 09:02:18 +05:30
Sojan Jose
8f1a1e0905 fix: Stop overwritting contact avatars unneccesarily (#8710)
While debugging a sentry error for "ActiveRecord::InvalidForeignKey ActiveStorage::Representations::RedirectController", it was noticed that we enqueue a Avatar::AvatarFromUrlJob for each setUser call, which is unnecessary. Hence making this call only if the contact doesn't have an existing avatar.

If one needs to have this avatar updated, they can go to the contacts tab and delete the current avatar, Chatwoot will pick up the new avatar in subsequent API call.
2024-01-16 16:38:46 +04:00
Nithin David Thomas
d1e7e75638 feat: Adds internal support for markdown in Telegram outgoing messages (#8640)
This PR adds support for Markdown in the telegram API for send message. The dashboard uses commonmark syntax for markdown but telegram is using MarkdownV2.
More info - https://core.telegram.org/bots/api#markdownv2-style

Adds support for bold - *bold*, _italic text_, __underline__, ~strikethrough~

Co-authored-by: Sojan Jose <sojan@pepalo.com>
2024-01-16 13:32:59 +04:00
Vishnu Narayanan
e7e14f01e4 fix: undefined method 'zero?' for nil:NilClass (#8689) 2024-01-15 15:07:36 +05:30
Muhsin Keloth
d305c5fd0f fix: Check the file attachment URL exists before downloading attachments in Telegram. (#8679)
In rare cases, the API call to Telegram for the file path fails. We were logging the error in sentry, switching to logs instead.

Co-authored-by: Sojan <sojan@pepalo.com>
2024-01-11 17:25:46 -08:00
Muhsin Keloth
1577288843 fix: Twilo attachment download fallback to the step where authorization headers are not passed. (#8681)
In the previous release, we enabled "HTTP Basic Authentication" to secure all attachments requiring HTTP authentication. This is particularly important for media files that may contain sensitive data, as recommended by Twilio. However, some users experienced issues because they did not enable this option despite our alerts prompting them to do so.  If the authenticated attachment download call fails, add another call to download the attachment without authentication.
2024-01-11 17:23:31 -08:00
Sojan Jose
35c26367da chore: Unset Redis config after spec (#8685)
The sentinel configuration set in this specification seems to be affecting other specifications. So, let's ensure that the memoised config variable gets unset after execution of the spec.
2024-01-10 15:32:48 -08:00
Sojan Jose
aaf4fee9a6 chore: Fix sentry errors in email processing for bounce notifications (#8677)
This case occurs for bounce notification emails where the from address is From: "" (Mail Delivery System) . We will be discarding these emails for now.

Fixes: https://linear.app/chatwoot/issue/CW-2793/activerecordrecordinvalid-validation-failed-email-invalid-email
2024-01-10 14:30:23 -08:00
Vishnu Narayanan
d731c972ad fix: skip auditlogs for whatsapp template sync (#8579)
Skips audit logs for whatsapp_template sync
Fixes: https://linear.app/chatwoot/issue/CW-2641/skip-whatsapp-template-updates-from-audit-logs
2024-01-09 21:51:48 -08:00
Shivam Mishra
56fbbe92b4 feat: trigger handoff when agent bot is the actor (#8639)
- This PR adds a feature to auto-trigger handoff events when an Agent bot toggles a conversation status from Pending to Open

Co-authored-by: Sojan <sojan@pepalo.com>
2024-01-05 15:26:52 -08:00
Shivam Mishra
6e30064421 feat: handle unsupported media on the backend (#8650)
This PR logs additional information in content_attributes of a message in case it is unsupported. This info can be used by the client to render a fresh UI
2024-01-05 13:05:00 -08:00
Muhsin Keloth
68062216e4 feat: Add a job to reopen snoozed notifications (#8545) 2024-01-05 15:13:22 +05:30
Sojan Jose
34675da6fa feat: Settings screen for custom branding (#8543)
- Ability to configure Chatwoot custom branding from UI when using paid plans

Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
2023-12-13 13:16:24 -08:00
Pranav Raj S
8c9a351c84 feat: Add support for ascending and descending options in sort (#8542) 2023-12-12 17:15:48 -08:00
Pranav Raj S
d28f512de4 fix: Update the label name to use .strip to avoid unnecessary whitespace characters (#8541)
- The cache stores the labels as label1, label2. Without removing the whitespace, the output of cached_label_list_array would be [label1, [whitespace]label2], which doesn't match with the existing labels. This list is returned with proper label names.
2023-12-12 15:04:29 -08:00
Sojan Jose
376de685fb chore: Adds API for agent bot avatar upload (#8533)
Adds API for agent bot avatar upload
- accounts/agent_bot
- platform/agent_bot
2023-12-11 19:02:11 -08:00
Pranav Raj S
890515edfd feat(perf): Cache labels on the conversation model (#8527) 2023-12-11 18:27:55 -08:00
Muhsin Keloth
db9a32a4c0 feat: Add sticker support in Line channel (#8488) 2023-12-10 20:45:44 -08:00
Sivin Varghese
27239ae14a feat: Adds API for retry messages in conversation (#8518) 2023-12-11 09:33:39 +05:30
Nithin David Thomas
f002870c6a feat: Super admin design improvements (#8517)
- Revamp the super admin design
- Introduce a new settings page for support and billing settings
- Move the access tokens into users, agent bots and platform app show pages


Co-authored-by: Sojan <sojan@pepalo.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2023-12-08 19:40:35 -08:00
Muhsin Keloth
b1a68759cf feat: Add the support for custom attributes in message variables (#8511) 2023-12-08 14:13:35 -08:00
Muhsin Keloth
bf49a17efa feat: Handle notification.deleted action cable event (#8501) 2023-12-06 16:49:00 +05:30
Muhsin Keloth
6b0d1d77d3 fix: Email notifications (#8502) 2023-12-06 15:50:23 +05:30
Muhsin Keloth
db33b7d1dc feat: Clear all previous notifications if a new notification is added to a conversation (#8490) 2023-12-06 14:03:43 +05:30
Muhsin Keloth
76711d95ff chore: Change primary actor to Conversation for all the notification types. (#8435) 2023-12-06 10:43:09 +05:30