feat: Add API to get the active contacts (#1313)

This commit is contained in:
Sojan Jose
2020-10-05 23:30:27 +05:30
committed by GitHub
parent 11725de09a
commit 88b2469dc8
6 changed files with 57 additions and 2 deletions

View File

@@ -37,9 +37,13 @@ module OnlineStatusTracker
format(::Redis::Alfred::ONLINE_STATUS, account_id: account_id)
end
def self.get_available_contact_ids(account_id)
::Redis::Alfred.zrangebyscore(presence_key(account_id, 'Contact'), (Time.zone.now - PRESENCE_DURATION).to_i, Time.now.to_i)
end
def self.get_available_contacts(account_id)
contact_ids = ::Redis::Alfred.zrangebyscore(presence_key(account_id, 'Contact'), (Time.zone.now - PRESENCE_DURATION).to_i, Time.now.to_i)
contact_ids.index_with { |_id| 'online' }
# returns {id1: 'online', id2: 'online'}
get_available_contact_ids(account_id).index_with { |_id| 'online' }
end
def self.get_available_users(account_id)