Mercurial Hosting > disearch
comparison src/choose_server.html.luan @ 13:af2b95854072
add server records
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 30 Oct 2023 21:32:42 -0600 |
parents | 3e2cb946d511 |
children |
comparison
equal
deleted
inserted
replaced
12:3e2cb946d511 | 13:af2b95854072 |
---|---|
13 local Shared = require "site:/lib/Shared.luan" | 13 local Shared = require "site:/lib/Shared.luan" |
14 local head = Shared.head or error() | 14 local head = Shared.head or error() |
15 local header = Shared.header or error() | 15 local header = Shared.header or error() |
16 local footer = Shared.footer or error() | 16 local footer = Shared.footer or error() |
17 local Config = require "site:/lib/Config.luan" | 17 local Config = require "site:/lib/Config.luan" |
18 local Utils = require "site:/lib/Utils.luan" | |
19 local list_to_set = Utils.list_to_set or error() | |
20 local Server = require "site:/lib/Server.luan" | |
18 local Logging = require "luan:logging/Logging.luan" | 21 local Logging = require "luan:logging/Logging.luan" |
19 local logger = Logging.logger "choose_server.html" | 22 local logger = Logging.logger "choose_server.html" |
20 | 23 |
21 | 24 |
22 local function get_access_token() | 25 local function get_access_token() |
59 } | 62 } |
60 local result = uri(url,options).read_text() | 63 local result = uri(url,options).read_text() |
61 -- logger.info(result) | 64 -- logger.info(result) |
62 result = json_parse(result) | 65 result = json_parse(result) |
63 -- logger.info(stringify(result)) | 66 -- logger.info(stringify(result)) |
67 | |
68 local set = list_to_set{} | |
69 for _, server in ipairs(Server.get_user_servers()) do | |
70 set[server.discord_id] = true | |
71 end | |
72 | |
64 local servers = {} | 73 local servers = {} |
65 for _, server in ipairs(result) do | 74 for _, server in ipairs(result) do |
66 if server.owner then | 75 if server.owner and not set[server.id] then |
67 servers[#servers+1] = server | 76 servers[#servers+1] = server |
68 end | 77 end |
69 end | 78 end |
70 logger.info(stringify(servers)) | 79 logger.info(stringify(servers)) |
71 | 80 |