Mercurial Hosting > chat
comparison src/lib/Shared.luan @ 15:8b8905f63d80
add get_chats
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sun, 03 Nov 2024 17:36:49 -0700 |
| parents | 9f45d32670ae |
| children | 82b55186a4a0 |
comparison
equal
deleted
inserted
replaced
| 14:0df3a63a895f | 15:8b8905f63d80 |
|---|---|
| 11 local html_encode = Html.encode or error() | 11 local html_encode = Html.encode or error() |
| 12 local Mail = require "luan:mail/Mail.luan" | 12 local Mail = require "luan:mail/Mail.luan" |
| 13 local User = require "site:/lib/User.luan" | 13 local User = require "site:/lib/User.luan" |
| 14 local current_user = User.current or error() | 14 local current_user = User.current or error() |
| 15 local get_user_by_id = User.get_by_id or error() | 15 local get_user_by_id = User.get_by_id or error() |
| 16 local Chat = require "site:/lib/Chat.luan" | |
| 17 local chat_search = Chat.search or error() | |
| 16 | 18 |
| 17 | 19 |
| 18 local Shared = {} | 20 local Shared = {} |
| 19 | 21 |
| 20 local started = Time.now() | 22 local started = Time.now() |
| 98 <div text><%= html_encode(post.content) %></div> | 100 <div text><%= html_encode(post.content) %></div> |
| 99 </div> | 101 </div> |
| 100 <% | 102 <% |
| 101 end | 103 end |
| 102 | 104 |
| 105 function Shared.chats_html() | |
| 106 local user = current_user() or error() | |
| 107 local chats = chat_search( "chat_user_ids:"..user.id, "chat_updated desc" ) | |
| 108 for _, chat in ipairs(chats) do | |
| 109 %> | |
| 110 <div chat="<%=chat.id%>" onclick="selectChat(this)"><%= chat.other_users_email(user) %></div> | |
| 111 <% | |
| 112 end | |
| 113 end | |
| 114 | |
| 103 return Shared | 115 return Shared |
