Chatwoot/app/models/contact.rb
Sojan Jose c21c839dca
Contact model changes (#184)
* move source id from contacts

* Fix contactInbox model name

* rubocop fix

* Fix rspec
2019-10-27 13:14:36 +05:30

23 lines
543 B
Ruby

class Contact < ApplicationRecord
include Pubsubable
validates :account_id, presence: true
belongs_to :account
has_many :conversations, dependent: :destroy
has_many :contact_inboxes, dependent: :destroy
has_many :inboxes, through: :contact_inboxes
mount_uploader :avatar, AvatarUploader
def get_source_id(inbox_id)
contact_inboxes.find_by!(inbox_id: inbox_id).source_id
end
def push_event_data
{
id: id,
name: name,
thumbnail: avatar.thumb.url,
pubsub_token: pubsub_token
}
end
end