Restructure omni services and add Chatwoot research snapshot

This commit is contained in:
Ruslan Bakiev
2026-02-21 11:11:27 +07:00
parent edea7a0034
commit b73babbbf6
7732 changed files with 978203 additions and 32 deletions

View File

@@ -0,0 +1,41 @@
# == Schema Information
#
# Table name: conversation_participants
#
# id :bigint not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
# account_id :bigint not null
# conversation_id :bigint not null
# user_id :bigint not null
#
# Indexes
#
# index_conversation_participants_on_account_id (account_id)
# index_conversation_participants_on_conversation_id (conversation_id)
# index_conversation_participants_on_user_id (user_id)
# index_conversation_participants_on_user_id_and_conversation_id (user_id,conversation_id) UNIQUE
#
class ConversationParticipant < ApplicationRecord
validates :account_id, presence: true
validates :conversation_id, presence: true
validates :user_id, presence: true
validates :user_id, uniqueness: { scope: [:conversation_id] }
validate :ensure_inbox_access
belongs_to :account
belongs_to :conversation
belongs_to :user
before_validation :ensure_account_id
private
def ensure_account_id
self.account_id = conversation&.account_id
end
def ensure_inbox_access
errors.add(:user, 'must have inbox access') if conversation && conversation.inbox.assignable_agents.exclude?(user)
end
end