view src/save_voice.js.luan @ 49:080eb027d93d

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 28 Feb 2025 20:27:34 -0700
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