# HG changeset patch # User Florian Zeitz # Date 1293135391 -3600 # Node ID a9e69088e67813e91017330916c79e26fc54c31d # Parent 94fab3c0a7aa4c04bdf2d031faaafa92e5665cc7 mod_adhoc_web: Put pubsubHost into js from lua. Compat with util.pubsub changes diff -r 94fab3c0a7aa -r a9e69088e678 mod_admin_web/admin_web/mod_admin_web.lua --- a/mod_admin_web/admin_web/mod_admin_web.lua Thu Dec 23 20:00:34 2010 +0100 +++ b/mod_admin_web/admin_web/mod_admin_web.lua Thu Dec 23 21:16:31 2010 +0100 @@ -52,7 +52,7 @@ if session.compressed then item:tag("compressed"):up(); end - hosts[service].modules.pubsub.service:publish(xmlns_sessions, host, id, item); + hosts[service].modules.pubsub.service:publish(xmlns_sessions, service, id, item); module:log("debug", "Added host " .. name .. " s2s" .. type); end @@ -61,7 +61,7 @@ local id = idmap[name.."_"..type]; if id then local notifier = stanza.stanza("retract", { id = id }); - hosts[service].modules.pubsub.service:retract(xmlns_sessions, host, id, notifier); + hosts[service].modules.pubsub.service:retract(xmlns_sessions, service, id, notifier); end end @@ -94,6 +94,7 @@ local f, err = open(full_path, "rb"); if not f then return response_404; end local data = f:read("*a"); + data = data:gsub("%%PUBSUBHOST%%", service); f:close(); if not data then return response_403; @@ -117,7 +118,10 @@ local host_session = prosody.hosts[host]; local http_conf = config.get("*", "core", "webadmin_http_ports"); - hosts[service].modules.pubsub.service:create(xmlns_sessions, host); + local ok, errmsg = hosts[service].modules.pubsub.service:create(xmlns_sessions, service); + if not ok then + error("Could not create node: " .. tostring(errmsg)); + end for remotehost, session in pairs(host_session.s2sout) do if session.type ~= "s2sout_unauthed" then diff -r 94fab3c0a7aa -r a9e69088e678 mod_admin_web/admin_web/www_files/js/main.js --- a/mod_admin_web/admin_web/www_files/js/main.js Thu Dec 23 20:00:34 2010 +0100 +++ b/mod_admin_web/admin_web/www_files/js/main.js Thu Dec 23 21:16:31 2010 +0100 @@ -8,7 +8,7 @@ var localJID = null; var connection = null; -var pubsubHost = null; /* TODO: Replace this inside Lua */ +var pubsubHost = '%PUBSUBHOST%'; function log(msg) { var entry = $('
').append(document.createTextNode(msg)); @@ -62,7 +62,6 @@ } else if (status == Strophe.Status.CONNECTED) { log('Strophe is connected.'); showDisconnect(); - pubsubHost = 'pubsub.' + connection.domain; connection.send($iq({to: pubsubHost, type: 'set', id: connection.getUniqueId()}).c('pubsub', {xmlns: Strophe.NS.PUBSUB}) .c('subscribe', {node: Strophe.NS.S2SPUBSUB, jid: connection.jid})); connection.addHandler(_cbNewS2S, Strophe.NS.PUBSUB + '#event', 'message');