Merge branch 'hotfix/21.56.9' into master
[gitter.git] / modules / presence / redis-lua / presence-eyeballs-off.lua
blob8cadf7e8ada77e540d99abb76fc340f0a684fe11
1 local key_socket = KEYS[1];
2 local key_troupe_users = KEYS[2];
3 local key_user_lock = KEYS[3];
5 local user_id = ARGV[1];
7 if redis.call("HDEL", key_socket, "eb") == 0 then
8 return { 0 }
9 end
11 redis.call("INCR", key_user_lock);
12 redis.call("EXPIRE", key_user_lock, 10);
15 local user_in_troupe_count = redis.call("ZINCRBY", key_troupe_users, -1, user_id)
16 redis.call("ZREMRANGEBYSCORE", key_troupe_users, '-inf', '0')
18 local total_in_troupe_count = redis.call("ZCARD", key_troupe_users)
20 return { 1, user_in_troupe_count, total_in_troupe_count }