diff src/heartbeat.js.luan @ 75:377bdda60f0b

read up to
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Mar 2025 18:26:49 -0600
parents a63faf49e1d7
children 2158a5950fcd
line wrap: on
line diff
--- a/src/heartbeat.js.luan	Sun Mar 09 10:55:30 2025 -0600
+++ b/src/heartbeat.js.luan	Sun Mar 09 18:26:49 2025 -0600
@@ -1,5 +1,6 @@
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
+local ipairs = Luan.ipairs or error()
 local String = require "luan:String.luan"
 local to_number = String.to_number or error()
 local Parsers = require "luan:Parsers.luan"
@@ -10,11 +11,14 @@
 local Http = require "luan:http/Http.luan"
 local User = require "site:/lib/User.luan"
 local current_user = User.current or error()
+local get_user_by_id = User.get_by_id or error()
 local Shared = require "site:/lib/Shared.luan"
 local compressed = Shared.compressed or error()
 local Online = require "site:/lib/Online.luan"
 local set_online = Online.set or error()
 local get_online = Online.get or error()
+local Chat = require "site:/lib/Chat.luan"
+local get_chat_by_id = Chat.get_by_id or error()
 local Logging = require "luan:logging/Logging.luan"
 local logger = Logging.logger "heartbeat.js"
 
@@ -40,4 +44,16 @@
 	online = <%=json_string(online,compressed)%>;
 	showOnline();
 <%
+	local chat = Http.request.parameters.chat
+	if chat ~= nil then
+		chat = get_chat_by_id(chat) or error()
+		local my_user_id = user.id
+		for _, user_id in ipairs(chat.user_ids) do
+			if user_id == my_user_id then continue end
+			local user = get_user_by_id(user_id)
+%>
+			readUpTo(<%=user_id%>,<%=json_string(user.name_html())%>,<%=chat.unread(user)%>);
+<%
+		end
+	end
 end