Mercurial > prosody-modules
diff mod_pubsub_hub/mod_pubsub_hub.lua @ 1324:853a382c9bd6
mod_turncredentials: Advertise the XEP-0215 feature (thanks Gryffus)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 28 Feb 2014 15:36:06 +0100 |
parents | 133ee88d19ae |
children | b21236b6b8d8 |
line wrap: on
line diff
--- a/mod_pubsub_hub/mod_pubsub_hub.lua Wed Feb 26 13:08:47 2014 -0800 +++ b/mod_pubsub_hub/mod_pubsub_hub.lua Fri Feb 28 15:36:06 2014 +0100 @@ -2,15 +2,14 @@ -- -- This file is MIT/X11 licensed. -local http = require "net.http"; -local formdecode = http.formdecode; -local formencode = http.formencode; +local http_request, formdecode, formencode = import("net.http", "request", "formdecode", "formencode"); local uuid = require "util.uuid".generate; local hmac_sha1 = require "util.hmac".sha1; local json_encode = require "util.json".encode; local time = os.time; local m_min, m_max = math.min, math.max; local tostring = tostring; + local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; local xmlns_pubsub_event = xmlns_pubsub .. "#event"; local subs_by_topic = module:shared"subscriptions"; @@ -91,7 +90,7 @@ module:log("debug", require"util.serialization".serialize(verify_modes)); if verify_modes["async"] then module:log("debug", "Sending async verification request to %s for %s", tostring(callback_url), tostring(subscription)); - http.request(callback_url, nil, function(body, code) + http_request(callback_url, nil, function(body, code) if body == challenge and code > 199 and code < 300 then if not subscription.want_state then module:log("warn", "Verification of already verified request, probably"); @@ -109,7 +108,7 @@ end) return 202; elseif verify_modes["sync"] then - http.request(callback_url, nil, function(body, code) + http_request(callback_url, nil, function(body, code) if body == challenge and code > 199 and code < 300 then if not subscription.want_state then module:log("warn", "Verification of already verified request, probably"); @@ -161,7 +160,7 @@ ["hub.lease_seconds"] = subscription.lease_seconds, ["hub.verify_token"] = subscription.verify_token, } - http.request(callback_url, nil, function(body, code) + http_request(callback_url, nil, function(body, code) if body == challenge and code > 199 and code < 300 then subscription.expires = now + subscription.lease_seconds; end @@ -201,7 +200,7 @@ if subscription.secret then headers["X-Hub-Signature"] = "sha1="..hmac_sha1(subscription.secret, body, true); end - http.request(subscription.callback, { method = "POST", body = body, headers = headers }, function(body, code) + http_request(subscription.callback, { method = "POST", body = body, headers = headers }, function(body, code) if code >= 200 and code <= 299 then module:log("debug", "Delivered"); else