diff src/save_voice.js.luan @ 41:818697418dbe

add voice link
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 27 Feb 2025 19:05:57 -0700
parents src/save_notify.js.luan@7ea33179592a
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/save_voice.js.luan	Thu Feb 27 19:05:57 2025 -0700
@@ -0,0 +1,20 @@
+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