chatwoot/app/models/concerns
Muhsin Keloth d0ecdc14d8
feat(webhooks): Emit inbox_updated when an inbox is disconnected (#14504)
Chatwoot now lets external apps know when an inbox loses its connection
and needs re-authentication. When a channel's authorization expires (for
example, an email inbox disconnects), Chatwoot fires an `inbox_updated`
webhook reflecting the new `reauthorization_required` status, and fires
it again once the inbox is re-authenticated. Integrators can keep their
own view of which inboxes are healthy without polling the API.

This is gated behind the `ENABLE_INBOX_EVENTS` installation flag — the
**Inbox updated** webhook subscription only appears in the dashboard
when that flag is enabled, so no event is offered that the backend
wouldn't dispatch.

Fixes
https://linear.app/chatwoot/issue/CW-7148/emit-inbox-webhook-when-an-inbox-is-disconnected

## How to test

1. Set `ENABLE_INBOX_EVENTS=true` and restart the app.
2. In **Settings → Integrations → Webhooks**, add a webhook and
subscribe to **Inbox updated**.
3. Disconnect an inbox — let an email/Instagram channel hit its
auth-error threshold, or run `inbox.channel.prompt_reauthorization!` in
a console.
4. The endpoint receives an `inbox_updated` event whose
`changed_attributes` shows `reauthorization_required` flipping to
`true`.
5. Re-authenticate the inbox (or run `inbox.channel.reauthorized!`) —
the endpoint receives the `true → false` transition.
6. Confirm the **Inbox updated** option is hidden when
`ENABLE_INBOX_EVENTS` is unset.

---------

Co-authored-by: Muhsin <12408980+muhsin-k@users.noreply.github.com>
2026-05-22 09:00:18 +04:00
..
.keep Initial Commit 2019-08-14 15:18:44 +05:30
access_tokenable.rb Chore: Replaced dependent destroy with dependent destroy_async in all models (#3249) 2021-11-18 10:32:29 +05:30
account_cache_revalidator.rb feat: expiry for cache keys [CW-3038] (#8793) 2024-01-29 15:27:26 +05:30
account_captain_auto_resolve.rb feat: Add force legacy auto-resolve flag (#13804) 2026-03-13 15:04:58 -07:00
account_email_rate_limitable.rb fix: Skip email rate limiting for self-hosted instances (#13915) 2026-03-26 18:06:10 +05:30
account_settings_schema.rb fix: validate support_email format and handle parse errors in mailer (#13958) 2026-04-13 19:06:06 +07:00
activity_message_handler.rb feat: show assignment policy name in auto-assignment activity messages (#13598) 2026-02-24 13:32:54 +05:30
assignee_activity_message_handler.rb feat: show assignment policy name in auto-assignment activity messages (#13598) 2026-02-24 13:32:54 +05:30
assignment_handler.rb feat: Add support for multi-language support for Captain (#11068) 2025-03-19 18:25:33 -07:00
auto_assignment_handler.rb fix: atomically claim conversation to prevent duplicate assignment (#14495) 2026-05-21 16:14:28 +05:30
availability_statusable.rb chore: Move agent availability to Account level (#3074) 2021-10-07 13:21:46 +05:30
avatarable.rb fix: [CW-6931] Harden external downloads against SSRF [avatar from url job] (#14153) 2026-04-24 18:59:45 +05:30
cache_keys.rb feat: Unread Count: added api, store refresher, invalidation and events (2/3)[CW-6851] (#14369) 2026-05-20 17:36:09 +05:30
captain_featurable.rb feat: add global config for captain settings (#13141) 2026-01-12 19:54:19 +05:30
channelable.rb chore: Centralize outgoing message reply restrictions for all the channels (#11279) 2025-04-12 08:52:12 +05:30
content_attribute_validator.rb chore: Upgrade rails and ruby versions (#2400) 2021-08-03 20:11:52 +05:30
conversation_mute_helpers.rb fix: prevent NoMethodError in mute helpers when contact is nil (#13277) 2026-01-15 22:00:09 -08:00
email_address_parseable.rb fix: validate support_email format and handle parse errors in mailer (#13958) 2026-04-13 19:06:06 +07:00
featurable.rb chore: Enable the new Rubocop rules (#7122) 2023-05-19 14:37:10 +05:30
inbox_agent_availability.rb feat: Assignment service (v2) (#12320) 2025-11-17 10:08:25 +05:30
json_schema_validator.rb feat: Add support for minutes in auto resolve feature (#11269) 2025-05-07 00:36:15 -07:00
label_activity_message_handler.rb feat: add activity message for SLA (#9100) 2024-03-13 20:05:34 +05:30
labelable.rb feat: Add support for labels in automations (#11658) 2025-09-18 14:17:54 +05:30
liquidable.rb fix: render agent variables in automation messages (#14338) 2026-05-04 13:25:40 +05:30
llm_formattable.rb chore: Update LLM formatter classes to include additional details (#11491) 2025-05-15 17:47:37 -07:00
message_filter_helpers.rb fix: Skip notifications for private notes (#13617) 2026-02-23 15:40:54 +04:00
out_of_offisable.rb perf: eliminate N+1 queries on inboxes#index (#14451) 2026-05-14 14:20:52 +05:30
priority_activity_message_handler.rb chore(i18n): Improvements in automation and macros (#11231) 2025-04-02 15:48:42 -07:00
pubsubable.rb chore: Rotate pubsub token on password change (#7194) 2023-05-27 13:24:31 +05:30
push_data_helper.rb fix: strip markdown hard-break backslashes from webhook payloads (#13950) 2026-04-16 13:19:35 +05:30
reauthorizable.rb feat(webhooks): Emit inbox_updated when an inbox is disconnected (#14504) 2026-05-22 09:00:18 +04:00
reportable.rb Chore: clean up Reporting Events (#4044) 2022-02-28 18:16:12 +05:30
sla_activity_message_handler.rb feat: add activity message for SLA (#9100) 2024-03-13 20:05:34 +05:30
sort_handler.rb fix(perf): force better index for pending_reponses longest first sort (#14291) 2026-04-28 18:50:29 +07:00
sso_authenticatable.rb feat: Prevent saving preferences and status when impersonating (#11164) 2025-05-20 17:34:30 -07:00
team_activity_message_handler.rb feat: add activity message for SLA (#9100) 2024-03-13 20:05:34 +05:30
user_attribute_helpers.rb chore: Account switching issue in newly added accounts (#12403) 2025-09-10 14:12:22 +05:30
webhook_secretable.rb feat: sign webhooks for API channel and agentbots (#13892) 2026-04-06 15:28:25 +05:30