comparison src/lib/Chat.luan @ 12:9f45d32670ae

server push
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 31 Oct 2024 21:40:57 -0600
parents 563a5358f2ee
children e2b7f6393dab
comparison
equal deleted inserted replaced
11:563a5358f2ee 12:9f45d32670ae
4 local Table = require "luan:Table.luan" 4 local Table = require "luan:Table.luan"
5 local concat = Table.concat or error() 5 local concat = Table.concat or error()
6 local is_empty = Table.is_empty or error() 6 local is_empty = Table.is_empty or error()
7 local Time = require "luan:Time.luan" 7 local Time = require "luan:Time.luan"
8 local time_now = Time.now or error() 8 local time_now = Time.now or error()
9 local Http = require "luan:http/Http.luan"
9 local Db = require "site:/lib/Db.luan" 10 local Db = require "site:/lib/Db.luan"
10 local run_in_transaction = Db.run_in_transaction or error() 11 local run_in_transaction = Db.run_in_transaction or error()
12 local Utils = require "site:/lib/Utils.luan"
13 local base_url = Utils.base_url or error()
11 14
12 15
13 local Chat = {} 16 local Chat = {}
14 17
15 local function from_doc(doc) 18 local function from_doc(doc)
60 end 63 end
61 end 64 end
62 return concat( t, ", " ) 65 return concat( t, ", " )
63 end 66 end
64 67
68 function chat.http_push(message)
69 local url = base_url().."/chat/"..chat.id
70 Http.push(url,message)
71 end
72
65 return chat 73 return chat
66 end 74 end
67 75
68 function Chat.search(query,sort,rows) 76 function Chat.search(query,sort,rows)
69 rows = rows or 1000000 77 rows = rows or 1000000