Files
leadchat/app/models/concerns/availability_statusable.rb
Sojan Jose c98907db49 Feature: Availability Statuses (#874)
Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
2020-07-04 11:42:47 +05:30

21 lines
522 B
Ruby

module AvailabilityStatusable
extend ActiveSupport::Concern
def online_presence?
::OnlineStatusTracker.get_presence(availability_account_id, self.class.name, id)
end
def availability_status
return 'offline' unless online_presence?
return 'online' if is_a? Contact
::OnlineStatusTracker.get_status(availability_account_id, id) || 'online'
end
def availability_account_id
return account_id if is_a? Contact
Current.account.present? ? Current.account.id : accounts.first.id
end
end