view src/save_voice.js.luan @ 93:d0566cc4a2ac default tip

uploa fix
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Apr 2025 19:47:48 -0600
parents 818697418dbe
children
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local Http = require "luan:http/Http.luan"
local Db = require "site:/lib/Db.luan"
local run_in_transaction = Db.run_in_transaction or error()
local User = require "site:/lib/User.luan"
local current_user = User.current or error()


return function()
	local url = Http.request.parameters.url or error()
	if url == "" then
		url = nil
	end
	run_in_transaction( function()
		local user = current_user() or error()
		user.voice_url = url
		user.save()
	end )
end