2019-08-14 09:48:44 +00:00
|
|
|
class Contact < ApplicationRecord
|
2019-10-16 22:18:48 +00:00
|
|
|
include Pubsubable
|
2019-10-20 08:47:26 +00:00
|
|
|
|
2019-08-14 09:48:44 +00:00
|
|
|
validates :account_id, presence: true
|
|
|
|
validates :inbox_id, presence: true
|
|
|
|
|
|
|
|
belongs_to :account
|
|
|
|
belongs_to :inbox
|
2019-10-20 19:10:18 +00:00
|
|
|
has_many :conversations, dependent: :destroy
|
2019-08-14 09:48:44 +00:00
|
|
|
mount_uploader :avatar, AvatarUploader
|
|
|
|
|
|
|
|
def push_event_data
|
|
|
|
{
|
|
|
|
id: id,
|
|
|
|
name: name,
|
|
|
|
thumbnail: avatar.thumb.url,
|
|
|
|
channel: inbox.try(:channel).try(:name),
|
2019-10-16 21:48:07 +00:00
|
|
|
pubsub_token: pubsub_token
|
2019-08-14 09:48:44 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|