comparison src/lib/Shared.luan @ 69:e229f4aacde0

config in lucene
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 06 Mar 2025 20:08:19 -0700
parents 8270106644db
children a63faf49e1d7
comparison
equal deleted inserted replaced
68:329c3f70fd78 69:e229f4aacde0
1 local Luan = require "luan:Luan.luan" 1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error 2 local error = Luan.error
3 local ipairs = Luan.ipairs or error() 3 local ipairs = Luan.ipairs or error()
4 local parse = Luan.parse or error() 4 local parse = Luan.parse or error()
5 local Io = require "luan:Io.luan"
6 local uri = Io.uri or error()
7 local Time = require "luan:Time.luan" 5 local Time = require "luan:Time.luan"
8 local Thread = require "luan:Thread.luan" 6 local Thread = require "luan:Thread.luan"
9 local thread_run = Thread.run or error() 7 local thread_run = Thread.run or error()
10 local Html = require "luan:Html.luan" 8 local Html = require "luan:Html.luan"
11 local html_encode = Html.encode or error() 9 local html_encode = Html.encode or error()
16 local get_user_by_id = User.get_by_id or error() 14 local get_user_by_id = User.get_by_id or error()
17 local Chat = require "site:/lib/Chat.luan" 15 local Chat = require "site:/lib/Chat.luan"
18 local chat_search = Chat.search or error() 16 local chat_search = Chat.search or error()
19 local Utils = require "site:/lib/Utils.luan" 17 local Utils = require "site:/lib/Utils.luan"
20 local base_url = Utils.base_url or error() 18 local base_url = Utils.base_url or error()
19 local Db = require "site:/lib/Db.luan"
21 local Logging = require "luan:logging/Logging.luan" 20 local Logging = require "luan:logging/Logging.luan"
22 local logger = Logging.logger "Shared" 21 local logger = Logging.logger "Shared"
23 22
24 23
25 local Shared = {} 24 local Shared = {}
85 [[<a href="/private/">private</a>]] 84 [[<a href="/private/">private</a>]]
86 [[<a href="/private/tools/">tools</a>]] 85 [[<a href="/private/tools/">tools</a>]]
87 } 86 }
88 end 87 end
89 88
90 local config_file = uri("site:/private/local/config.luano")
91 Shared.config_file = config_file
92
93 do 89 do
94 if config_file.exists() then 90 local doc = Db.get_document("type:config")
95 Shared.config = parse( config_file.read_text() ) 91 if doc ~= nil then
92 Shared.config = parse( doc.config )
96 else 93 else
97 Shared.config = { 94 Shared.config = {
98 mail_server = { 95 mail_server = {
99 host = "smtpcorp.com" 96 host = "mail.smtp2go.com"
100 port = 465 97 port = 465
101 username = "xxx" 98 username = "xxx"
102 password = "xxx" 99 password = "xxx"
103 } 100 }
104 } 101 }
112 send_mail0(mail) 109 send_mail0(mail)
113 end 110 end
114 111
115 function Shared.send_mail_async(mail) 112 function Shared.send_mail_async(mail)
116 mail.From = mail.From or default_from 113 mail.From = mail.From or default_from
117 logger.info(mail.From)
118 thread_run( function() 114 thread_run( function()
119 send_mail0(mail) 115 send_mail0(mail)
120 end ) 116 end )
121 end 117 end
122 118