From cb6dde19e5a7a288917194a3106f5177e0f0920a Mon Sep 17 00:00:00 2001 From: AliasAlreadyTaken Date: Sat, 26 Feb 2022 22:38:27 +0100 Subject: [PATCH] Token works --- init.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index eeef44a..4a548c4 100644 --- a/init.lua +++ b/init.lua @@ -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)