Token works

This commit is contained in:
AliasAlreadyTaken 2022-02-26 22:38:27 +01:00
parent a02bcef7ad
commit cb6dde19e5
1 changed files with 6 additions and 1 deletions

View File

@ -36,7 +36,9 @@ assert(http, "[MOD] yl_matterbridge: Please add yl_matterbridge to secure.http_m
function send(user_name, message_text)
local url = "http://" .. address .. ":" .. port .. "/api/message"
local post_headers = {"Content-Type: application/json, "}
local post_headers = {"Content-Type: application/json"}
if token and token ~= "" then table.insert(post_headers,"Authorization: Bearer "..token) end
core.log("action", "[MOD] yl_matterbridge : Posted " .. dump(post_headers))
local timeout = 10
local data = {
text = message_text,
@ -66,11 +68,14 @@ end
local function receive()
local url = "http://" .. address .. ":" .. port .. "/api/messages"
local post_headers = {"Content-Type: application/json"}
if token and token ~= "" then table.insert(post_headers,"Authorization: Bearer "..token) end
local timeout = 0
http.fetch(
{
url = url,
extra_headers = post_headers,
timeout = timeout
},
function(result)