view src/bump.js.luan @ 19:b386303be994

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 02 Nov 2023 21:00:37 -0600
parents 552d6f944acb
children
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local Time = require "luan:Time.luan"
local time_now = Time.now or error()
local Io = require "luan:Io.luan"
local Http = require "luan:http/Http.luan"
local Server = require "site:/lib/Server.luan"
local Utils = require "site:/lib/Utils.luan"
local get_user = Utils.get_user or error()
local Db = require "site:/lib/Db.luan"
local run_in_transaction = Db.run_in_transaction or error()


return function()
	local server_id = Http.request.parameters.server or error()
	run_in_transaction( function()
		local server = Server.get_by_id(server_id) or error()
		server.owner_discord_id == get_user() or error()
		server.bumped = time_now()
		server.save()
	end )
	Io.stdout = Http.response.text_writer()
%>
	location.reload();
<%
end