annotate src/delete_server.js.luan @ 13:af2b95854072

add server records
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 30 Oct 2023 21:32:42 -0600
parents
children 80105b716a62
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Io = require "luan:Io.luan"
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local Http = require "luan:http/Http.luan"
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Server = require "site:/lib/Server.luan"
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local Utils = require "site:/lib/Utils.luan"
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local get_user = Utils.get_user or error()
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 return function()
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 local server_id = Http.request.parameters.server or error()
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local server = Server.get_by_id(server_id)
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 server.owner_discord_id == get_user() or error()
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 server.delete()
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 Io.stdout = Http.response.text_writer()
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 %>
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 location.reload();
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 <%
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 end