comparison mod_admin_web/admin_web/mod_admin_web.lua @ 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 9233d7ee3c09
children e373de5907aa
comparison
equal deleted inserted replaced
291:94fab3c0a7aa 292:a9e69088e678
50 item:tag("encrypted"):up(); 50 item:tag("encrypted"):up();
51 end 51 end
52 if session.compressed then 52 if session.compressed then
53 item:tag("compressed"):up(); 53 item:tag("compressed"):up();
54 end 54 end
55 hosts[service].modules.pubsub.service:publish(xmlns_sessions, host, id, item); 55 hosts[service].modules.pubsub.service:publish(xmlns_sessions, service, id, item);
56 module:log("debug", "Added host " .. name .. " s2s" .. type); 56 module:log("debug", "Added host " .. name .. " s2s" .. type);
57 end 57 end
58 58
59 function del_host(session, type) 59 function del_host(session, type)
60 local name = (type == "out" and session.to_host) or (type == "in" and session.from_host); 60 local name = (type == "out" and session.to_host) or (type == "in" and session.from_host);
61 local id = idmap[name.."_"..type]; 61 local id = idmap[name.."_"..type];
62 if id then 62 if id then
63 local notifier = stanza.stanza("retract", { id = id }); 63 local notifier = stanza.stanza("retract", { id = id });
64 hosts[service].modules.pubsub.service:retract(xmlns_sessions, host, id, notifier); 64 hosts[service].modules.pubsub.service:retract(xmlns_sessions, service, id, notifier);
65 end 65 end
66 end 66 end
67 67
68 local function preprocess_path(path) 68 local function preprocess_path(path)
69 if path:sub(1,1) ~= "/" then 69 if path:sub(1,1) ~= "/" then
92 return response_403; 92 return response_403;
93 end 93 end
94 local f, err = open(full_path, "rb"); 94 local f, err = open(full_path, "rb");
95 if not f then return response_404; end 95 if not f then return response_404; end
96 local data = f:read("*a"); 96 local data = f:read("*a");
97 data = data:gsub("%%PUBSUBHOST%%", service);
97 f:close(); 98 f:close();
98 if not data then 99 if not data then
99 return response_403; 100 return response_403;
100 end 101 end
101 local ext = path:match("%.([^.]*)$"); 102 local ext = path:match("%.([^.]*)$");
115 116
116 function module.load() 117 function module.load()
117 local host_session = prosody.hosts[host]; 118 local host_session = prosody.hosts[host];
118 local http_conf = config.get("*", "core", "webadmin_http_ports"); 119 local http_conf = config.get("*", "core", "webadmin_http_ports");
119 120
120 hosts[service].modules.pubsub.service:create(xmlns_sessions, host); 121 local ok, errmsg = hosts[service].modules.pubsub.service:create(xmlns_sessions, service);
122 if not ok then
123 error("Could not create node: " .. tostring(errmsg));
124 end
121 125
122 for remotehost, session in pairs(host_session.s2sout) do 126 for remotehost, session in pairs(host_session.s2sout) do
123 if session.type ~= "s2sout_unauthed" then 127 if session.type ~= "s2sout_unauthed" then
124 add_host(session, "out"); 128 add_host(session, "out");
125 end 129 end