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

uploa fix
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Apr 2025 19:47:48 -0600
parents 7ea33179592a
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 email = Http.request.parameters.email or error()
	local multi = Http.request.parameters.multi or error()
	run_in_transaction( function()
		local user = current_user() or error()
		user.notify_email = email ~= "" and email or nil
		user.multi_notify = multi == "true"
		user.save()
	end )
end