Chore: Fix presence for current user (#1001)

Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
Sojan Jose
2020-07-04 20:03:16 +05:30
committed by GitHub
parent 4612494923
commit 43147b3163
11 changed files with 78 additions and 20 deletions

View File

@@ -44,6 +44,8 @@ module OnlineStatusTracker
def self.get_available_users(account_id)
user_ids = ::Redis::Alfred.zrangebyscore(presence_key(account_id, 'User'), (Time.zone.now - PRESENCE_DURATION).to_i, Time.now.to_i)
return {} if user_ids.blank?
user_availabilities = ::Redis::Alfred.hmget(status_key(account_id), user_ids)
user_ids.map.with_index { |id, index| [id, (user_availabilities[index] || 'online')] }.to_h
end