annotate src/lib/Shared.luan @ 86:625ffdf6499d

web app
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 12 Mar 2025 12:26:19 -0600
parents a47036fd0158
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local ipairs = Luan.ipairs or error()
1
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
4 local parse = Luan.parse or error()
83
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
5 local Table = require "luan:Table.luan"
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
6 local concat = Table.concat or error()
3
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
7 local Time = require "luan:Time.luan"
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
8 local Thread = require "luan:Thread.luan"
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
9 local thread_run = Thread.run or error()
12
9f45d32670ae server push
Franklin Schmidt <fschmidt@gmail.com>
parents: 10
diff changeset
10 local Html = require "luan:Html.luan"
9f45d32670ae server push
Franklin Schmidt <fschmidt@gmail.com>
parents: 10
diff changeset
11 local html_encode = Html.encode or error()
16
82b55186a4a0 fix delete_chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
12 local Http = require "luan:http/Http.luan"
3
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
13 local Mail = require "luan:mail/Mail.luan"
2
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
14 local User = require "site:/lib/User.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
15 local current_user = User.current or error()
12
9f45d32670ae server push
Franklin Schmidt <fschmidt@gmail.com>
parents: 10
diff changeset
16 local get_user_by_id = User.get_by_id or error()
15
8b8905f63d80 add get_chats
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
17 local Chat = require "site:/lib/Chat.luan"
8b8905f63d80 add get_chats
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
18 local chat_search = Chat.search or error()
16
82b55186a4a0 fix delete_chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
19 local Utils = require "site:/lib/Utils.luan"
82b55186a4a0 fix delete_chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
20 local base_url = Utils.base_url or error()
69
e229f4aacde0 config in lucene
Franklin Schmidt <fschmidt@gmail.com>
parents: 59
diff changeset
21 local Db = require "site:/lib/Db.luan"
79
Franklin Schmidt <fschmidt@gmail.com>
parents: 73
diff changeset
22 local Post = require "site:/lib/Post.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents: 73
diff changeset
23 local get_post_by_id = Post.get_by_id or error()
45
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
24 local Logging = require "luan:logging/Logging.luan"
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
25 local logger = Logging.logger "Shared"
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 local Shared = {}
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29
3
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
30 local started = Time.now()
10
f9e6a4cc4f7d add Post
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
31 Shared.started = started
3
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
32
45
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
33 local title
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
34 local domain = Http.domain
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
35 if domain == "chat.luan.software" then
51
38c209714df9 rename to Luan Chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 46
diff changeset
36 title = "Luan Chat"
45
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
37 elseif domain == "test.chat.luan.software" then
51
38c209714df9 rename to Luan Chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 46
diff changeset
38 title = "Luan Chat test"
45
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
39 elseif domain == nil then
51
38c209714df9 rename to Luan Chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 46
diff changeset
40 title = "Luan Chat local"
45
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
41 else
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
42 error(domain)
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
43 end
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
44 Shared.title = title
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
45
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 function Shared.head()
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 <meta name="viewport" content="width=device-width, initial-scale=1">
86
625ffdf6499d web app
Franklin Schmidt <fschmidt@gmail.com>
parents: 83
diff changeset
49 <link rel="manifest" href="/manifest.json" />
45
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
50 <title><%=title%></title>
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 <style>
3
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
52 @import "/site.css?s=<%=started%>";
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 </style>
3
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
54 <script src="/site.js?s=<%=started%>"></script>
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 <%
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
56 end
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
57
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
58 local function header(crumbs)
2
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
59 local user = current_user()
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
60 %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
61 <div header>
2
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
62 <span>
51
38c209714df9 rename to Luan Chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 46
diff changeset
63 <a href="/">Luan Chat</a>
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
64 <% for _, crumb in ipairs(crumbs or {}) do %>
2
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
65 / <%=crumb%>
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
66 <% end %>
2
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
67 </span>
41
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
68 <span right>
2
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
69 <% if user == nil then %>
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
70 <a href="/login.html">Login / Register</a>
41
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
71 <% else
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
72 local voice_url = user.voice_url
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
73 if voice_url ~= nil then
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
74 %>
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
75 <a href="<%=voice_url%>" title="Call" target="voice"><img phone src="/images/call.svg"></a>
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
76 <%
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
77 end
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
78 %>
2
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
79 <a href="/account.html"><%= user.email %></a>
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
80 <% end %>
Franklin Schmidt <fschmidt@gmail.com>
parents: 1
diff changeset
81 </span>
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
82 </div>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
83 <%
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
84 end
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
85 Shared.header = header
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
86
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
87 function Shared.private_header()
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
88 header{
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
89 [[<a href="/private/">private</a>]]
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
90 [[<a href="/private/tools/">tools</a>]]
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
91 }
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
92 end
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
93
1
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
94 do
69
e229f4aacde0 config in lucene
Franklin Schmidt <fschmidt@gmail.com>
parents: 59
diff changeset
95 local doc = Db.get_document("type:config")
e229f4aacde0 config in lucene
Franklin Schmidt <fschmidt@gmail.com>
parents: 59
diff changeset
96 if doc ~= nil then
e229f4aacde0 config in lucene
Franklin Schmidt <fschmidt@gmail.com>
parents: 59
diff changeset
97 Shared.config = parse( doc.config )
1
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
98 else
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
99 Shared.config = {
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
100 mail_server = {
69
e229f4aacde0 config in lucene
Franklin Schmidt <fschmidt@gmail.com>
parents: 59
diff changeset
101 host = "mail.smtp2go.com"
1
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
102 port = 465
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
103 username = "xxx"
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
104 password = "xxx"
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
105 }
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
106 }
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
107 end
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
108 end
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
109
45
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
110 local default_from = title.." <chat@luan.software>"
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
111 local send_mail0 = Mail.sender(Shared.config.mail_server).send
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
112 function Shared.send_mail(mail)
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
113 mail.From = mail.From or default_from
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
114 send_mail0(mail)
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
115 end
3
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
116
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
117 function Shared.send_mail_async(mail)
45
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
118 mail.From = mail.From or default_from
3
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
119 thread_run( function()
45
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 41
diff changeset
120 send_mail0(mail)
3
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
121 end )
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
122 end
2c63b10781e1 add login
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
123
12
9f45d32670ae server push
Franklin Schmidt <fschmidt@gmail.com>
parents: 10
diff changeset
124 function Shared.post_html(post)
22
949914955bfe add menu
Franklin Schmidt <fschmidt@gmail.com>
parents: 19
diff changeset
125 local author_id = post.author_id
949914955bfe add menu
Franklin Schmidt <fschmidt@gmail.com>
parents: 19
diff changeset
126 local user = current_user() or error()
949914955bfe add menu
Franklin Schmidt <fschmidt@gmail.com>
parents: 19
diff changeset
127 local author = get_user_by_id(author_id)
12
9f45d32670ae server push
Franklin Schmidt <fschmidt@gmail.com>
parents: 10
diff changeset
128 local id = post.id
79
Franklin Schmidt <fschmidt@gmail.com>
parents: 73
diff changeset
129 local reply = post.reply
Franklin Schmidt <fschmidt@gmail.com>
parents: 73
diff changeset
130 reply = reply and get_post_by_id(reply)
12
9f45d32670ae server push
Franklin Schmidt <fschmidt@gmail.com>
parents: 10
diff changeset
131 %>
79
Franklin Schmidt <fschmidt@gmail.com>
parents: 73
diff changeset
132 <div post="<%=id%>" author="<%=author.id%>" id="p<%=id%>" fix>
35
27c41f22d2a9 improve fixPosts
Franklin Schmidt <fschmidt@gmail.com>
parents: 34
diff changeset
133 <div who>
46
42b741a1d5c6 add username
Franklin Schmidt <fschmidt@gmail.com>
parents: 45
diff changeset
134 <span author><%=author.name_html()%></span>
34
Franklin Schmidt <fschmidt@gmail.com>
parents: 33
diff changeset
135 <span right>
35
27c41f22d2a9 improve fixPosts
Franklin Schmidt <fschmidt@gmail.com>
parents: 34
diff changeset
136 <span when><%=post.date%></span>
27c41f22d2a9 improve fixPosts
Franklin Schmidt <fschmidt@gmail.com>
parents: 34
diff changeset
137 <span pulldown></span>
34
Franklin Schmidt <fschmidt@gmail.com>
parents: 33
diff changeset
138 </span>
12
9f45d32670ae server push
Franklin Schmidt <fschmidt@gmail.com>
parents: 10
diff changeset
139 </div>
79
Franklin Schmidt <fschmidt@gmail.com>
parents: 73
diff changeset
140 <% if reply ~= nil then %>
Franklin Schmidt <fschmidt@gmail.com>
parents: 73
diff changeset
141 <div quote>
Franklin Schmidt <fschmidt@gmail.com>
parents: 73
diff changeset
142 <blockquote><%= html_encode(reply.content) %></blockquote>
Franklin Schmidt <fschmidt@gmail.com>
parents: 73
diff changeset
143 <div><a when href="#p<%=reply.id%>"><%=reply.date%></a></div>
Franklin Schmidt <fschmidt@gmail.com>
parents: 73
diff changeset
144 </div>
Franklin Schmidt <fschmidt@gmail.com>
parents: 73
diff changeset
145 <% end %>
35
27c41f22d2a9 improve fixPosts
Franklin Schmidt <fschmidt@gmail.com>
parents: 34
diff changeset
146 <div text><%= html_encode(post.content) %></div>
12
9f45d32670ae server push
Franklin Schmidt <fschmidt@gmail.com>
parents: 10
diff changeset
147 </div>
9f45d32670ae server push
Franklin Schmidt <fschmidt@gmail.com>
parents: 10
diff changeset
148 <%
9f45d32670ae server push
Franklin Schmidt <fschmidt@gmail.com>
parents: 10
diff changeset
149 end
9f45d32670ae server push
Franklin Schmidt <fschmidt@gmail.com>
parents: 10
diff changeset
150
83
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
151 local function group_name(user_ids)
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
152 local t = {nil}
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
153 for _, user_id in ipairs(user_ids) do
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
154 t[#t+1] = get_user_by_id(user_id).name_html()
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
155 end
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
156 return concat(t,", ")
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
157 end
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
158 Shared.group_name = group_name
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
159
15
8b8905f63d80 add get_chats
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
160 function Shared.chats_html()
8b8905f63d80 add get_chats
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
161 local user = current_user() or error()
8b8905f63d80 add get_chats
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
162 local chats = chat_search( "chat_user_ids:"..user.id, "chat_updated desc" )
8b8905f63d80 add get_chats
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
163 for _, chat in ipairs(chats) do
59
8270106644db add chat.luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 53
diff changeset
164 local chat_id = chat.id
53
9298b04607ae add unread
Franklin Schmidt <fschmidt@gmail.com>
parents: 51
diff changeset
165 local unread = chat.unread(user)
15
8b8905f63d80 add get_chats
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
166 %>
59
8270106644db add chat.luan
Franklin Schmidt <fschmidt@gmail.com>
parents: 53
diff changeset
167 <div chat="<%=chat_id%>" onclick="selectChat('<%=chat_id%>')">
83
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
168 <%
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
169 local user_ids = chat.other_user_ids(user.id)
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
170 if #user_ids > 1 then
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
171 %>
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
172 <%= group_name(user_ids) %>
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
173 <%
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
174 else
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
175 local other_user = get_user_by_id(user_ids[1]) or error()
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
176 %>
53
9298b04607ae add unread
Franklin Schmidt <fschmidt@gmail.com>
parents: 51
diff changeset
177 <%= other_user.name_html() %>
9298b04607ae add unread
Franklin Schmidt <fschmidt@gmail.com>
parents: 51
diff changeset
178 <span online="<%= other_user.id %>"></span>
83
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
179 <%
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
180 end
a47036fd0158 group chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 79
diff changeset
181 %>
53
9298b04607ae add unread
Franklin Schmidt <fschmidt@gmail.com>
parents: 51
diff changeset
182 <span unread="<%=unread%>"><%=unread%></span>
9298b04607ae add unread
Franklin Schmidt <fschmidt@gmail.com>
parents: 51
diff changeset
183 </div>
15
8b8905f63d80 add get_chats
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
184 <%
8b8905f63d80 add get_chats
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
185 end
8b8905f63d80 add get_chats
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
186 end
8b8905f63d80 add get_chats
Franklin Schmidt <fschmidt@gmail.com>
parents: 12
diff changeset
187
16
82b55186a4a0 fix delete_chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
188 function Shared.http_push_to_users(user_ids,message)
82b55186a4a0 fix delete_chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
189 local base = base_url().."/user/"
82b55186a4a0 fix delete_chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
190 for _, user_id in ipairs(user_ids) do
82b55186a4a0 fix delete_chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
191 local url = base..user_id
82b55186a4a0 fix delete_chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
192 Http.push(url,message)
82b55186a4a0 fix delete_chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
193 end
82b55186a4a0 fix delete_chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
194 end
82b55186a4a0 fix delete_chat
Franklin Schmidt <fschmidt@gmail.com>
parents: 15
diff changeset
195
73
a63faf49e1d7 last seen
Franklin Schmidt <fschmidt@gmail.com>
parents: 69
diff changeset
196 Shared.compressed = {compressed=true}
a63faf49e1d7 last seen
Franklin Schmidt <fschmidt@gmail.com>
parents: 69
diff changeset
197
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
198 return Shared