Feature: Availability Statuses (#874)
Co-authored-by: Pranav Raj S <pranav@thoughtwoot.com>
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
module AvailabilityStatusable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def online?
|
||||
::OnlineStatusTracker.subscription_count(pubsub_token) != 0
|
||||
def online_presence?
|
||||
::OnlineStatusTracker.get_presence(availability_account_id, self.class.name, id)
|
||||
end
|
||||
|
||||
def availability_status
|
||||
online? ? 'online' : 'offline'
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user