view src/bump.js.luan @ 16:552d6f944acb

add bump
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 01 Nov 2023 17:34:15 -0600
parents
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