Changeset

292:a9e69088e678

mod_adhoc_web: Put pubsubHost into js from lua. Compat with util.pubsub changes
author Florian Zeitz <florob@babelmonkeys.de>
date Thu, 23 Dec 2010 21:16:31 +0100
parents 291:94fab3c0a7aa
children 293:d76f47a608ab
files mod_admin_web/admin_web/mod_admin_web.lua mod_admin_web/admin_web/www_files/js/main.js
diffstat 2 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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 = $('<div></div>').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');