Mercurial Hosting > disearch
diff src/add_server.js.luan @ 13:af2b95854072
add server records
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 30 Oct 2023 21:32:42 -0600 |
parents | 3e2cb946d511 |
children | 552d6f944acb |
line wrap: on
line diff
--- a/src/add_server.js.luan Mon Oct 30 14:59:45 2023 -0600 +++ b/src/add_server.js.luan Mon Oct 30 21:32:42 2023 -0600 @@ -6,6 +6,11 @@ local Http = require "luan:http/Http.luan" local Shared = require "site:/lib/Shared.luan" local js_error = Shared.js_error or error() +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() local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "add_server.js" @@ -25,6 +30,16 @@ js_error( "invite", [[Invalid Discord invite URL]] ) return end + run_in_transaction( function() + local server = Server.new{ + owner_discord_id = get_user() or error() + discord_id = id + name = name + icon = icon + invite = invite + } + server.save() + end ) %> location = '/servers.html'; <%