mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
* Feature: Add online status to each user * Add OnlineStatusable, add availability status to thumbnail
20 lines
491 B
Ruby
20 lines
491 B
Ruby
module OnlineStatusTracker
|
|
def self.add_subscription(channel_id)
|
|
count = subscription_count(channel_id)
|
|
::Redis::Alfred.setex(channel_id, count + 1)
|
|
end
|
|
|
|
def self.remove_subscription(channel_id)
|
|
count = subscription_count(channel_id)
|
|
if count == 1
|
|
::Redis::Alfred.delete(channel_id)
|
|
elsif count != 0
|
|
::Redis::Alfred.setex(channel_id, count - 1)
|
|
end
|
|
end
|
|
|
|
def self.subscription_count(channel_id)
|
|
::Redis::Alfred.get(channel_id).to_i
|
|
end
|
|
end
|