Chore: Fix presence for current user (#1001)
Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
@@ -2,19 +2,29 @@ module AvailabilityStatusable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def online_presence?
|
||||
return if user_profile_page_context?
|
||||
|
||||
::OnlineStatusTracker.get_presence(availability_account_id, self.class.name, id)
|
||||
end
|
||||
|
||||
def availability_status
|
||||
return availability if user_profile_page_context?
|
||||
return 'offline' unless online_presence?
|
||||
return 'online' if is_a? Contact
|
||||
|
||||
::OnlineStatusTracker.get_status(availability_account_id, id) || 'online'
|
||||
end
|
||||
|
||||
def user_profile_page_context?
|
||||
# at the moment profile pages aren't account scoped
|
||||
# hence we will return availability attribute instead of true presence
|
||||
# we will revisit this later
|
||||
is_a?(User) && Current.account.blank?
|
||||
end
|
||||
|
||||
def availability_account_id
|
||||
return account_id if is_a? Contact
|
||||
|
||||
Current.account.present? ? Current.account.id : accounts.first.id
|
||||
Current.account.id
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user