Mercurial Hosting > chat
diff src/add_post.js.luan @ 79:b5a316575e64
reply
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 10 Mar 2025 21:41:53 -0600 |
parents | d4d154b404f8 |
children | c41e200c3e76 |
line wrap: on
line diff
--- a/src/add_post.js.luan Sun Mar 09 22:20:36 2025 -0600 +++ b/src/add_post.js.luan Mon Mar 10 21:41:53 2025 -0600 @@ -3,6 +3,8 @@ local ipairs = Luan.ipairs or error() local Time = require "luan:Time.luan" local time_now = Time.now or error() +local String = require "luan:String.luan" +local to_number = String.to_number or error() local Parsers = require "luan:Parsers.luan" local json_string = Parsers.json_string or error() local Io = require "luan:Io.luan" @@ -29,12 +31,17 @@ local now = time_now() run_in_transaction( function() chat = get_chat_by_id(chat) or error() - post = new_post{ + post = { chat_id = chat.id author_id = user.id date = now content = content } + local reply = Http.request.parameters.reply + if reply ~= nil then + post.reply = to_number(reply) or error() + end + post = new_post(post) post.save() chat.updated = now chat.save()