iachat/app/jobs
Gabriel Jablonski 079d4b4996
fix(conversations): enforce NOT NULL on contact_id + cleanup orphans (#273)
* fix(conversations): enforce NOT NULL + FK on contact_id

Conversations had contact_id nullable with no FK to contacts. Combined
with dependent: :destroy_async on Contact#conversations, deleting a
contact could leave conversations pointing to a missing contact,
breaking the conversations#index API with
"undefined method 'additional_attributes' for nil" from the contact
partial.

Changes:
- Migration cleans up existing orphans, sets contact_id NOT NULL and
  adds a FK with ON DELETE CASCADE so the invariant is enforced at the
  DB level (complements the existing Rails presence validation).
- ContactMergeAction uses update_all for conversations/messages/notes/
  contact_inboxes so a failing callback cannot silently leave records
  pointing to the mergee contact before it is destroyed.
- Drop the now-redundant orphan filter in Conversations::ResolutionJob
  and its spec; the invariant is enforced at the schema level.

* fix: address review feedback

- Drop the ON DELETE CASCADE FK on conversations.contact_id. Several
  conversation-owned tables (messages, mentions, conversation_participants,
  reporting_events, csat_survey_responses, calls, applied_slas, sla_events,
  and polymorphic notifications) still have plain conversation_id references
  without FK cascades. The DB-level cascade would skip Conversation's
  dependent: cleanup and replace the NULL-contact bug with orphan children,
  and would also conflict with the existing non-cascade FKs on
  scheduled_messages/recurring_scheduled_messages. Keep the invariant at the
  Rails layer (NOT NULL + presence validation + dependent: :destroy_async).
- Clean up orphan conversations in the migration via Rails destroy so
  dependent associations are propagated correctly, instead of a raw
  DELETE FROM conversations that would orphan all child rows.
- Revert ContactMergeAction.merge_* methods back to per-record update! so
  Conversation#after_update_commit still fires (notify_status_change /
  CONVERSATION_CONTACT_CHANGED) for contact_id changes. The bang form
  still removes the silent-failure risk of the original .update call.
2026-04-22 13:57:40 -03:00
..
account feat: account enrichment using context.dev [UPM-27] (#13978) 2026-04-08 11:16:52 +05:30
agent_bots feat: sign webhooks for API channel and agentbots (#13892) 2026-04-06 15:28:25 +05:30
agents feat(internal-chat): implement internal chat system for agents (#247) 2026-04-11 13:50:15 -03:00
auto_assignment Chore/merge upstream 4.8.0 (#150) 2025-11-19 16:25:58 -03:00
avatar Merge branch 'chatwoot/develop' into chore/merge-upstream-4.12.0 2026-03-20 00:27:45 -03:00
campaigns chore: one off SMS campaign APIs (#2589) 2021-07-14 12:24:09 +05:30
channels fix: z-api read message (#165) 2025-12-12 09:58:12 -03:00
companies feat: Add automatic favicon fetching for companies (#13013) 2026-03-05 18:51:28 -08:00
contacts feat: group conversations (#228) 2026-03-19 21:56:58 -03:00
conversations fix(conversations): enforce NOT NULL on contact_id + cleanup orphans (#273) 2026-04-22 13:57:40 -03:00
crm feat: integrate LeadSquared CRM (#11284) 2025-04-29 09:14:00 +05:30
inboxes fix: handle ioerror in imap fetch (#13960) 2026-04-10 13:31:28 +05:30
internal feat(internal-chat): implement internal chat system for agents (#247) 2026-04-11 13:50:15 -03:00
labels fix: Update associations when a label is updated (#3046) 2021-09-21 10:16:32 +05:30
migration Chore/merge upstream 4.8.0 (#150) 2025-11-19 16:25:58 -03:00
notification perf: limit the number of notifications per user to 300 (#13234) 2026-01-28 17:35:13 +05:30
scheduled_messages feat: schedule messages recurrence (#240) 2026-03-19 22:51:14 -03:00
webhooks Merge branch 'main' into chore/merge-upstream-4.11.0 2026-02-17 23:05:26 -03:00
action_cable_broadcast_job.rb chore: Add more conversation events for reload (#10877) 2025-02-11 00:33:45 -08:00
application_job.rb chore: Improve active job error logs for deserialization error (#8742) 2024-01-18 19:27:18 +04:00
bulk_actions_job.rb chore: apply Rails/SaveBang cop (#15) 2025-04-03 23:29:24 -03:00
contact_ip_lookup_job.rb feat(poc): Disable widget based on country (#6658) 2023-03-14 09:09:57 -07:00
conversation_reply_email_job.rb feat: add per-account daily rate limit for outbound emails (#13411) 2026-02-03 02:06:51 +05:30
data_import_job.rb fix: Avoid double notification email after importing contacts (#13150) 2026-01-09 15:11:19 -08:00
delete_object_job.rb fix: Prevent SLA deletion timeouts by moving to async job (#12944) 2025-12-10 12:28:47 +05:30
event_dispatcher_job.rb chore: Reorganize Sidekiq Queues (#6976) 2023-05-04 15:44:16 +05:30
hook_job.rb feat: integrate LeadSquared CRM (#11284) 2025-04-29 09:14:00 +05:30
macros_execution_job.rb feat: Execute macro actions, for the conversation (#5066) 2022-07-26 12:41:22 +05:30
mutex_application_job.rb fix: mutex timeout and error handling (#8770) 2024-01-24 14:18:21 +04:00
send_on_slack_job.rb fix: mutex timeout and error handling (#8770) 2024-01-24 14:18:21 +04:00
send_reply_job.rb fix(jobs): resolve channel service class by name in SendReplyJob 2026-04-17 21:24:29 -03:00
slack_unfurl_job.rb feat: Support link unfurling for all the channels within the same connected channel account. (#8033) 2023-10-08 17:55:03 +05:30
trigger_scheduled_items_job.rb Merge branch 'main' into chore/merge-upstream-4.11.0 2026-02-17 23:05:26 -03:00
webhook_job.rb Merge branch 'chatwoot/develop' into chore/merge-upstream-4.12.0 2026-03-20 00:27:45 -03:00