Mercurial Hosting > chat
diff src/heartbeat.js.luan @ 33:e2b7f6393dab
add online
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 10 Nov 2024 19:57:14 -0700 |
parents | f4708943f29e |
children | 62d04ca486dd |
line wrap: on
line diff
--- a/src/heartbeat.js.luan Sat Nov 09 21:41:11 2024 -0700 +++ b/src/heartbeat.js.luan Sun Nov 10 19:57:14 2024 -0700 @@ -8,18 +8,24 @@ local Http = require "luan:http/Http.luan" local User = require "site:/lib/User.luan" local current_user = User.current or error() +local Shared = require "site:/lib/Shared.luan" +local http_push_to_users = Shared.http_push_to_users or error() local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "heartbeat.js" return function() + local user = current_user() or error() + local user_ids = user.chatting_with_ids() + local js = "setOnline("..user.id..")" + http_push_to_users( user_ids, js ) + local last_update = Http.request.parameters.last_update or error() last_update = to_number(last_update) or error() - local user = current_user() or error() local user_last_update = user.last_update() local now = time_now() if now - user_last_update < 10000 or last_update >= user_last_update then - logger.info "ok" + -- logger.info "ok" return end logger.info "update"