Commit Graph
5590 Commits
Author SHA1 Message Date
Sivin VargheseandGitHub ce4d52926c Merge branch 'feature/stripe_v2' into feature/stripe_v2_fe 2025-11-06 16:34:03 +05:30
Tanmay Deep Sharma fb86b1354a make stripe billing version consistent 2025-11-06 15:31:06 +05:30
Tanmay Deep Sharma ab28802d5a update gemfile stripe version to alpha 2025-11-06 15:26:53 +05:30
Tanmay Deep Sharma 797714f5aa remove the billing config to render v2 2025-11-06 15:26:26 +05:30
Tanmay Deep Sharma b2cc5d113e update gemfile stripe version to alpha 2025-11-06 15:25:57 +05:30
Tanmay Deep Sharma 4eca7382f8 Merge remote-tracking branch 'origin/feature/stripe_v2' into feature/stripe_v2_fe 2025-11-06 14:10:44 +05:30
Tanmay Deep Sharma 0fe60d137e Merge remote-tracking branch 'origin/feature/stripe_v2_fe' into feature/stripe_v2_fe 2025-11-06 14:07:13 +05:30
Tanmay Deep Sharma f6ec3f3a72 use stripe gem beta version 2025-11-06 14:06:48 +05:30
Tanmay Deep Sharma d51148951f use stripe gem beta version 2025-11-06 13:38:47 +05:30
Tanmay Deep Sharma 79bb3d0ef3 update spec for handle stripe event 2025-11-06 03:38:09 +05:30
Tanmay Deep Sharma 7418882a4f make codebase a bit more modular 2025-11-06 03:32:43 +05:30
Tanmay Deep Sharma d38bd5139e set strip billing version in custom attributes 2025-11-06 02:07:44 +05:30
Tanmay Deep Sharma fcc6973245 remove pricing plan creation 2025-11-06 02:02:35 +05:30
Tanmay Deep Sharma 2590c57893 remove un-necessary serialisation 2025-11-05 23:52:22 +05:30
Tanmay Deep Sharma f225e2fcd8 add credit sync job 2025-11-05 23:32:07 +05:30
Tanmay Deep Sharma b626e0cbf1 use account limits to store the captain limits 2025-11-05 16:41:01 +05:30
Tanmay Deep Sharma eb4f93b821 use limits api to render usage 2025-11-05 16:40:47 +05:30
Tanmay Deep Sharma 4a0c61ddb7 use account limits to store the captain limits 2025-11-05 16:38:29 +05:30
Sivin VargheseandGitHub dc4dfe60e4 Merge branch 'feature/stripe_v2' into feature/stripe_v2_fe 2025-11-05 15:34:45 +05:30
Tanmay Deep Sharma d3b4c7225a Merge remote-tracking branch 'origin/feature/stripe_v2' into feature/stripe_v2_fe 2025-11-05 13:17:18 +05:30
Tanmay Deep Sharma 35f42e71f6 fix cursor review comments 2025-11-05 13:16:36 +05:30
Tanmay Deep Sharma eb04882e5a remove credit transactions table and use custome attributes instead 2025-11-05 12:37:23 +05:30
Shivam Mishra 3a4aa5f837 faet: update design for upgrade modal 2025-11-04 15:18:26 +05:30
Shivam Mishra bfb2d2b2bb fix: topup dialog discount 2025-11-04 14:46:39 +05:30
Shivam Mishra aa0f36245f fix: credit topup 2025-11-04 14:40:37 +05:30
Shivam Mishra 8f83d03354 feat: update credit balance UI 2025-11-04 14:15:32 +05:30
Shivam Mishra 643f7415c1 feat: cleanup plan summary 2025-11-04 13:43:56 +05:30
iamsivin ebee38d4a5 chore: Update num of seats design 2025-11-04 13:30:13 +05:30
Sivin VargheseandGitHub 16ac2dba17 Merge branch 'feature/stripe_v2' into feature/stripe_v2_fe 2025-11-04 11:28:10 +05:30
Tanmay Deep Sharma e511527f32 Merge remote-tracking branch 'origin/develop' into feature/stripe_v2 2025-11-04 11:25:28 +05:30
d9b840f161 fix: Optimize Message search_data to prevent OpenSearch field explosion (#12786)
## Description

Refactored the `Message#search_data` method to prevent exceeding
OpenSearch's 1000 field limit during reindex operations.

**Problem:** The previous implementation serialized entire ActiveRecord
objects (Inbox, Sender, Conversation) with all their JSONB fields,
causing dynamic field explosion in OpenSearch. This resulted in
`Searchkick::ImportError` with "Limit of total fields [1000] has been
exceeded".

**Solution:** Whitelisted only necessary fields for search and
filtering, and flattened JSONB `custom_attributes` into key-value pair
arrays to prevent unbounded field creation.

Linked to: CW-5861

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality not to work as expected)
- [x] This change requires a documentation update

## How Has This Been Tested?

- Verified rubocop passes with no offenses
- Code review of search field usage from
`enterprise/app/services/enterprise/search_service.rb`
- Analyzed actual search queries to determine required indexed fields

**Still needed:**
- Full reindex test on staging/production environment
- Verify search functionality still works after reindex
- Confirm field count is under 1000 limit

## Changes Made

### Before
- Indexed 1000+ fields (entire AR objects with JSONB)
- `inbox` = full Inbox object (23+ fields + JSONB)
- `sender` = full Contact/User/AgentBot object (10+ fields + JSONB)
- `conversation` = full push_event_data
- Dynamic JSONB keys creating unlimited fields

### After
- ~35-40 controlled fields
- Whitelisted search fields: `content`, `attachment_transcribed_text`,
`email_subject`
- Filter fields: `account_id`, `inbox_id`, `conversation_id`,
`sender_id`, `sender_type`, etc.
- Flattened `custom_attributes`: `[{key, value, value_type}]` format
- Helper methods: `search_conversation_data`, `search_inbox_data`,
`search_sender_data`, `search_additional_data`

## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules

## Post-merge Steps

After merging, the following steps are required:

1. **Reindex all messages:**
   ```bash
   bundle exec rails runner "Message.reindex"
   ```

2. **Verify field count:**
   ```bash
   bundle exec rails runner "
     client = Searchkick.client
     index_name = Message.searchkick_index.name
     mapping = client.indices.get_mapping(index: index_name)
     fields = mapping.dig(index_name, 'mappings', 'properties')
     puts 'Total fields: ' + fields.keys.count.to_s
   "
   ```

3. **Test search functionality** to ensure queries still work as
expected

---------

Co-authored-by: Vishnu Narayanan <iamwishnu@gmail.com>
Co-authored-by: Pranav <pranav@chatwoot.com>
2025-11-03 17:37:51 -08:00
1fbdd68222 feat: Add company auto-association for contacts (CW-5726 Part 2) (#12711)
## Description

Implements real-time company auto-association for contacts based on
email domains. This is **Part 2** of the company model production
rollout (CW-5726).

**Task:**
- When a contact is created with a business email, automatically create
and associate a company from the email domain
- When a contact is updated with an email for the first time (email was
previously nil), associate with a company
- Preserve existing company associations when email changes to avoid
user confusion
- Skip free email providers and disposable domains

**Dependencies:**
⚠️ Requires PR #12657 (Part 1: Backfill migration) to be merged first

**Linear ticket:**
[CW-5726](https://linear.app/chatwoot/issue/CW-5726/company-model-setting-it-up-on-production)

## Type of change

- [x] New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

- Service specs: Tests business email detection, company creation,
association logic, edge cases (existing companies, free emails, nil
emails)
- Integration specs: Tests full callback flow for contact create/update
scenarios
- All tests passing: 10 examples, 0 failures
- RuboCop: 0 offenses

## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented on my code, particularly in hard-to-understand
areas
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules (PR #12657 pending)

---------

Co-authored-by: Sojan Jose <sojan@pepalo.com>
2025-11-03 20:36:13 +05:30
ef54f07d5b feat: Add company backfill migration for existing contacts (Part 1) (#12657)
## Description

Implements company backfill migration infrastructure for existing
contacts. This is **Part 1 of 2** for the company model production
rollout as described in
[CW-5726](https://linear.app/chatwoot/issue/CW-5726/company-model-setting-it-up-on-production).

Creates jobs and services to associate existing contacts with companies
based on their email domains, filtering out free email providers (gmail,
yahoo, etc.) and disposable addresses.
 

**What's included:**
- Business email detector service with ValidEmail2 (uses
`disposable_domain?` to avoid DNS lookups)
- Per-account batch job to process contacts for one account
- Orchestrator job to iterate all accounts
- Rake task: `bundle exec rake companies:backfill`

~~*NOTE*: I'm using a hard-coded approach to determine if something is a
"business" email by filtering out emails that are usually personal. I've
also added domains that are common to some of our customers' regions.
This should be simpler. I looked into `Valid_Email2` and I couldn't find
anything to dictate whether an email is a personal email or a business
one. I don't think the approach used in the frontend is valid here.~~
UPDATE: Using `email_provider_info` gem instead.


**Pending - Part 2 (separate PR):** Real-time company creation for new
contacts

## Type of change

- [x] New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

```bash
# Run all new tests
bundle exec rspec spec/enterprise/services/companies/business_email_detector_service_spec.rb \\
                   spec/enterprise/jobs/migration/company_account_batch_job_spec.rb \\
                   spec/enterprise/jobs/migration/company_backfill_job_spec.rb

# Run RuboCop
bundle exec rubocop enterprise/app/services/companies/business_email_detector_service.rb \\
                     enterprise/app/jobs/migration/company_account_batch_job.rb \\
                     enterprise/app/jobs/migration/company_backfill_job.rb \\
                     lib/tasks/companies.rake
```

**Performance optimization:**
- Uses `disposable_domain?` instead of `disposable?` to avoid DNS MX
lookups (discovered via tcpdump analysis - `disposable?` was making
network calls for every email, causing 100x slowdown)

## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules

---------

Co-authored-by: Sojan Jose <sojan@pepalo.com>
2025-11-03 20:03:47 +05:30
iamsivin bd19d596b3 chore: Minor fix 2025-11-03 19:37:15 +05:30
iamsivin 6a0878f893 chore: Minor fix 2025-11-03 19:16:09 +05:30
iamsivin cdececcc67 chore: Clean up 2025-11-03 18:27:08 +05:30
iamsivin ffdcee7d86 chore: Improve transition 2025-11-03 17:32:01 +05:30
iamsivin 05c4ee099b chore: Fix flag 2025-11-03 16:26:44 +05:30
Chatwoot BotandGitHub e771d99552 chore: Update translations (#12748) 2025-11-03 15:45:32 +05:30
iamsivin 643316e19a chore: Update credit sections 2025-11-03 11:59:12 +05:30
iamsivin a0cc8e2f3f chore: Update the Pricing plan section 2025-10-31 18:03:45 +05:30
iamsivin fb0f5cd696 chore: Update credit grants 2025-10-31 15:46:52 +05:30
iamsivin 6211406681 chore: Minor fix 2025-10-31 14:18:54 +05:30
iamsivin 76ff8bdd35 chore: Update cancel sub modal 2025-10-31 14:17:25 +05:30
Muhsin KelothandGitHub 358a3924b8 chore: Add dependant destroy_async for sla events (#12774)
Added the destroy_async to prevent timeout during SLA policy deletion by
processing SLA events asynchronously.
2025-10-31 09:19:56 +05:30
Sivin VargheseandGitHub 6b87d6784e chore: Make contacts bulk action bar sticky (#12773)
# Pull Request Template

## Description

This PR makes the contacts bulk action bar sticky while scrolling.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)

## How Has This Been Tested?

### Screenshots
<img width="1080" height="300" alt="image"
src="https://github.com/user-attachments/assets/21f8f3c6-813e-4ef6-b40a-8dd14e6ffb26"
/>
<img width="1080" height="300" alt="image"
src="https://github.com/user-attachments/assets/bb939f1d-9a13-4f9f-953d-b9872c984b74"
/>



## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [ ] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
2025-10-30 11:57:46 -07:00
Vishnu NarayananandGitHub faaf67129e feat: Enable opensearch on paid plans automatically (#12770)
- enable `advanced_search feature` on all paid plans automatically

ref: https://github.com/chatwoot/chatwoot/pull/12503
2025-10-30 08:47:37 -07:00
Sivin VargheseandGitHub 10cd5da09d Merge branch 'feature/stripe_v2' into feature/stripe_v2_fe 2025-10-30 20:54:27 +05:30
Tanmay Deep Sharma ce5a859a4f create and pay an invoice on subscription change 2025-10-30 15:52:30 +05:30
Tanmay Deep Sharma 32e0915a20 create and pay an invoice on subscription change 2025-10-30 15:51:51 +05:30