Commit Graph
273 Commits
Author SHA1 Message Date
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 d51148951f use stripe gem beta version 2025-11-06 13:38:47 +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 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 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
Tanmay Deep Sharma e511527f32 Merge remote-tracking branch 'origin/develop' into feature/stripe_v2 2025-11-04 11:25:28 +05:30
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
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
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
Tanmay Deep Sharma ce5a859a4f create and pay an invoice on subscription change 2025-10-30 15:52:30 +05:30
Shivam MishraandGitHub d20de25da1 fix: run captain v2 outside the transaction (#12756) 2025-10-30 13:35:20 +05:30
Tanmay Deep Sharma 94985bbc77 remove update subscription flow overall 2025-10-29 21:37:06 +05:30
Tanmay Deep Sharma f31d9a3e76 store next billing dates 2025-10-29 20:30:16 +05:30
Tanmay Sharma 79082bea58 return failure in case event is blank 2025-10-29 17:48:09 +05:30
Tanmay Sharma b9f68fc839 do not deduct or refund credits for audio transactions 2025-10-29 17:46:39 +05:30
Tanmay Sharma e10ef03490 fix rspec for topup 2025-10-29 17:28:03 +05:30
Tanmay Deep Sharma 6f9f2c32c9 handle cancellation properly 2025-10-29 15:50:12 +05:30
38af08534c fix: Captain response builder not getting triggered (#12729)
## Summary
- Fix captain response builder not getting triggered for cases where
responses are created as completed.

## Testing Instructions 
- Test articles with firecrawl
- Test articles without firecrawl
- Test PDF documents

---------

Co-authored-by: Pranav <pranav@chatwoot.com>
2025-10-28 18:31:08 -07:00
Tanmay Deep Sharma f999112671 fix rspec 2025-10-29 03:24:12 +05:30
Tanmay Deep Sharma be37c5b80c sanity changes 2025-10-29 03:06:34 +05:30
Tanmay Deep Sharma 3970149b06 remove resume feature 2025-10-28 22:45:57 +05:30
Tanmay Deep Sharma 9c33ce50b3 Merge remote-tracking branch 'origin/develop' into feature/stripe_v2 2025-10-28 22:25:19 +05:30
Tanmay Deep Sharma 36a2412f42 support changing pricing plans 2025-10-28 22:22:48 +05:30
Tanmay Sharma 3ba4340042 remove update subscription flow 2025-10-27 14:16:39 +05:30
Tanmay Sharma 411048715d self review backend changes 2025-10-27 02:17:43 +05:30
Tanmay Sharma 39af360a18 implement checkout endpoint for subscription in a better way 2025-10-27 00:28:52 +05:30
PranavandGitHub 5891fd6f49 feat(ee): Add a service to fetch website content and prepare a persona of Captain Assistant (#12732)
This PR is the first of many to simplify the process of building an
assistant. The new flow will only require the user’s website. We’ll
automatically crawl it, identify the business name and what the business
does, and then generate a suggested assistant persona, complete with a
proposed name and description.

This service returns the following.
Example: tooljet.com
<img width="795" height="217" alt="Screenshot 2025-10-25 at 2 55 04 PM"
src="https://github.com/user-attachments/assets/9cb3594a-9c9c-4970-a0a1-4c9c8869c193"
/>

Example: replit.com
<img width="797" height="176" alt="Screenshot 2025-10-25 at 2 56 42 PM"
src="https://github.com/user-attachments/assets/6a1b4266-aab6-455f-a5e3-696d3a8243c9"
/>
2025-10-25 15:50:50 -07:00
Shivam MishraandGitHub 74fc9c0321 fix: parameterize agent name (#12709) 2025-10-23 13:51:07 +05:30
Sojan JoseandGitHub 9898ccee9e chore: Enforce custom role permissions on conversation access (#12583)
## Summary
- ensure conversation lookup uses the permission filter before fetching
records
- add request specs covering custom role access to unassigned
conversations

## Testing
- bundle exec rspec
spec/enterprise/controllers/api/v1/accounts/conversations_controller_spec.rb

------
https://chatgpt.com/codex/tasks/task_e_68de1f62b9b883268a54882e608a8bb8
2025-10-22 20:23:37 -07:00
Tanmay Sharma ac1743514b use env variable for stripe v2 2025-10-16 16:37:52 +05:30
Tanmay Sharma 7c3b07c507 code cleanup 2025-10-13 21:06:05 +05:30
Tanmay Sharma 62203da528 fix up extra env 2025-10-13 13:29:00 +05:30
Tanmay Sharma 029294e16b Merge remote-tracking branch 'origin/feature/stripe_v2' into feature/stripe_v2 2025-10-12 17:26:53 +05:30
Tanmay Sharma 2c095bed86 fix spec rubcop 2025-10-12 17:26:07 +05:30
Tanmay Deep SharmaandGitHub 7c6508dd04 Merge branch 'develop' into feature/stripe_v2 2025-10-12 15:47:27 +04:00
Tanmay Sharma cef23891af cleanup code, remove unnecessary 2025-10-12 17:02:16 +05:30
Tanmay Sharma 19a851c01d cleanup code, remove unnecessary 2025-10-11 11:56:16 +04:00
Tanmay Sharma a22e11c810 cleanup code 2025-10-11 10:25:58 +04:00
Tanmay Sharma efe6e64dcd cleanup code 2025-10-11 10:22:46 +04:00
Tanmay Deep Sharma d6f5c627eb fix rspec and customer subscription process 2025-10-10 13:03:27 +02:00
Tanmay Sharma 51b4a8f9fc cleanup 2025-10-09 17:38:27 +02:00
Tanmay Sharma 1268b2cf55 fix schema file 2025-10-09 16:24:32 +02:00
Tanmay Sharma 125ae5523a fix stripe v2 calls 2025-10-09 09:52:56 +02:00
Tanmay Deep Sharma 216a2c0e73 do not disable rubocop 2025-10-09 01:04:47 +02:00