plugins/mod_disco.lua
branch0.12
changeset 13412 d7857ef7843a
parent 12392 50fcd3879482
child 13413 95d8875c90dc
equal deleted inserted replaced
13382:db30ffbf2090 13412:d7857ef7843a
   170 	local username = jid_split(stanza.attr.to) or origin.username;
   170 	local username = jid_split(stanza.attr.to) or origin.username;
   171 	local is_admin = um_is_admin(stanza.attr.to or origin.full_jid, module.host)
   171 	local is_admin = um_is_admin(stanza.attr.to or origin.full_jid, module.host)
   172 	if not stanza.attr.to or (expose_admins and is_admin) or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then
   172 	if not stanza.attr.to or (expose_admins and is_admin) or is_contact_subscribed(username, module.host, jid_bare(stanza.attr.from)) then
   173 		if node and node ~= "" then
   173 		if node and node ~= "" then
   174 			local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#info', node=node});
   174 			local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#info', node=node});
       
   175 			reply:tag("feature", { var = "http://jabber.org/protocol/disco#info" }):up();
       
   176 			reply:tag("feature", { var = "http://jabber.org/protocol/disco#items" }):up();
   175 			if not reply.attr.from then reply.attr.from = origin.username.."@"..origin.host; end -- COMPAT To satisfy Psi when querying own account
   177 			if not reply.attr.from then reply.attr.from = origin.username.."@"..origin.host; end -- COMPAT To satisfy Psi when querying own account
   176 			local node_event = { origin = origin, stanza = stanza, reply = reply, node = node, exists = false};
   178 			local node_event = { origin = origin, stanza = stanza, reply = reply, node = node, exists = false};
   177 			local ret = module:fire_event("account-disco-info-node", node_event);
   179 			local ret = module:fire_event("account-disco-info-node", node_event);
   178 			if ret ~= nil then return ret; end
   180 			if ret ~= nil then return ret; end
   179 			if node_event.exists then
   181 			if node_event.exists then
   190 		elseif prosody.hosts[module.host].users.name == "anonymous" then
   192 		elseif prosody.hosts[module.host].users.name == "anonymous" then
   191 			reply:tag('identity', {category='account', type='anonymous'}):up();
   193 			reply:tag('identity', {category='account', type='anonymous'}):up();
   192 		else
   194 		else
   193 			reply:tag('identity', {category='account', type='registered'}):up();
   195 			reply:tag('identity', {category='account', type='registered'}):up();
   194 		end
   196 		end
       
   197 		reply:tag("feature", { var = "http://jabber.org/protocol/disco#info" }):up();
       
   198 		reply:tag("feature", { var = "http://jabber.org/protocol/disco#items" }):up();
   195 		module:fire_event("account-disco-info", { origin = origin, reply = reply });
   199 		module:fire_event("account-disco-info", { origin = origin, reply = reply });
   196 		origin.send(reply);
   200 		origin.send(reply);
   197 		return true;
   201 		return true;
   198 	end
   202 	end
   199 end);
   203 end);