local Luan = require "luan:Luan.luan" local error = Luan.error local ipairs = Luan.ipairs or error() local String = require "luan:String.luan" local digest_message = String.digest_message or error() local Parsers = require "luan:Parsers.luan" local json_string = Parsers.json_string or error() local Html = require "luan:Html.luan" local html_encode = Html.encode or error() local Math = require "luan:Math.luan" local random = Math.random or error() local Io = require "luan:Io.luan" 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 Chat = require "site:/lib/Chat.luan" local get_chat_by_id = Chat.get_by_id or error() local Post = require "site:/lib/Post.luan" local post_search = Post.search or error() local Shared = require "site:/lib/Shared.luan" local post_html = Shared.post_html or error() local group_name = Shared.group_name or error() local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "get_chat.js" local function get_html(user,chat) local spy = Http.request.cookies.spy ~= nil if not spy then chat.read(user) end local posts = post_search( "post_chat_id:"..chat.id, "id" ) %>

<% local user_ids = chat.other_user_ids(user.id) if #user_ids > 1 then %> <%= group_name(user_ids) %> <% else local other_user = get_user_by_id(user_ids[1]) or error() %> <%= other_user.name_html() %> <% local voice_url = other_user.voice_url if voice_url ~= nil then %> <% end end %>

People in Chat Mute Chat Add Someone to Chat Delete Old Messages Delete Chat
<% for _, post in ipairs(posts) do post_html(post) end %>
<% end local function people(chat) for _, user_id in ipairs(chat.user_ids) do local user = get_user_by_id(user_id) local name = user.name local email = user.email local voice_url = user.voice_url local voice = voice_url and `%> <%` or "" %>

<% if name == nil then %> <%=html_encode(email)%><%=voice%>
<% else %> <%=html_encode(name)%><%=voice%>
<%=html_encode(email)%>
<% end %>

<% end end return function() local user = current_user() or error() local chat = Http.request.parameters.chat or error() chat = get_chat_by_id(chat) or error() local html = `get_html(user,chat)` local digest = digest_message("MD5","luan chat "..random()) Io.stdout = Http.response.text_writer() %> gotChat(<%=json_string(html)%>); filebinUrl = 'https://filebin.net/<%=digest%>/'; document.querySelector('dialog[people] div[people]').innerHTML = <%=json_string(`people(chat)`)%>; <% end