Mercurial Hosting > chat
comparison src/lib/Shared.luan @ 45:e138343b2c76
unsubscribe and more
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Fri, 28 Feb 2025 14:37:11 -0700 |
| parents | 818697418dbe |
| children | 42b741a1d5c6 |
comparison
equal
deleted
inserted
replaced
| 44:1aa50739475a | 45:e138343b2c76 |
|---|---|
| 16 local get_user_by_id = User.get_by_id or error() | 16 local get_user_by_id = User.get_by_id or error() |
| 17 local Chat = require "site:/lib/Chat.luan" | 17 local Chat = require "site:/lib/Chat.luan" |
| 18 local chat_search = Chat.search or error() | 18 local chat_search = Chat.search or error() |
| 19 local Utils = require "site:/lib/Utils.luan" | 19 local Utils = require "site:/lib/Utils.luan" |
| 20 local base_url = Utils.base_url or error() | 20 local base_url = Utils.base_url or error() |
| 21 local Logging = require "luan:logging/Logging.luan" | |
| 22 local logger = Logging.logger "Shared" | |
| 21 | 23 |
| 22 | 24 |
| 23 local Shared = {} | 25 local Shared = {} |
| 24 | 26 |
| 25 local started = Time.now() | 27 local started = Time.now() |
| 26 Shared.started = started | 28 Shared.started = started |
| 27 | 29 |
| 30 local title | |
| 31 local domain = Http.domain | |
| 32 if domain == "chat.luan.software" then | |
| 33 title = "Web Chat" | |
| 34 elseif domain == "test.chat.luan.software" then | |
| 35 title = "Web Chat test" | |
| 36 elseif domain == nil then | |
| 37 title = "Web Chat local" | |
| 38 else | |
| 39 error(domain) | |
| 40 end | |
| 41 Shared.title = title | |
| 42 | |
| 28 function Shared.head() | 43 function Shared.head() |
| 29 %> | 44 %> |
| 30 <meta name="viewport" content="width=device-width, initial-scale=1"> | 45 <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 31 <title>Web Chat</title> | 46 <title><%=title%></title> |
| 32 <style> | 47 <style> |
| 33 @import "/site.css?s=<%=started%>"; | 48 @import "/site.css?s=<%=started%>"; |
| 34 </style> | 49 </style> |
| 35 <script src="/site.js?s=<%=started%>"></script> | 50 <script src="/site.js?s=<%=started%>"></script> |
| 36 <% | 51 <% |
| 88 } | 103 } |
| 89 } | 104 } |
| 90 end | 105 end |
| 91 end | 106 end |
| 92 | 107 |
| 93 local send_mail = Mail.sender(Shared.config.mail_server).send | 108 local default_from = title.." <chat@luan.software>" |
| 94 Shared.send_mail = send_mail | 109 local send_mail0 = Mail.sender(Shared.config.mail_server).send |
| 110 function Shared.send_mail(mail) | |
| 111 mail.From = mail.From or default_from | |
| 112 send_mail0(mail) | |
| 113 end | |
| 95 | 114 |
| 96 function Shared.send_mail_async(mail) | 115 function Shared.send_mail_async(mail) |
| 116 mail.From = mail.From or default_from | |
| 117 logger.info(mail.From) | |
| 97 thread_run( function() | 118 thread_run( function() |
| 98 send_mail(mail) | 119 send_mail0(mail) |
| 99 end ) | 120 end ) |
| 100 end | 121 end |
| 101 | 122 |
| 102 function Shared.post_html(post) | 123 function Shared.post_html(post) |
| 103 local author_id = post.author_id | 124 local author_id = post.author_id |
