changeset 759:6531a029fce5

mod_service_directories: Replace use of core_post_stanza() with module:send()
author Kim Alvefur <zash@zash.se>
date Wed, 01 Aug 2012 02:29:01 +0200
parents 295ae44b8a01
children 442f88b49d9b
files mod_service_directories/mod_service_directories.lua
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mod_service_directories/mod_service_directories.lua	Wed Aug 01 02:22:24 2012 +0200
+++ b/mod_service_directories/mod_service_directories.lua	Wed Aug 01 02:29:01 2012 +0200
@@ -14,7 +14,6 @@
 local adhoc_new = module:require "adhoc".new;
 local to_ascii = require "util.encodings".idna.to_ascii;
 local nameprep = require "util.encodings".stringprep.nameprep;
-local core_post_stanza = core_post_stanza;
 local pairs, ipairs = pairs, ipairs;
 local module = module;
 local hosts = hosts;
@@ -39,18 +38,18 @@
 
 	local t = stanza.attr.type;
 	if t == "probe" then
-		core_post_stanza(hosts[module.host], st.presence({ from = module.host, to = host, id = stanza.attr.id }));
+		module:send(st.presence({ from = module.host, to = host, id = stanza.attr.id }));
 	elseif t == "subscribe" then
 		subscription_from[host] = true;
-		core_post_stanza(hosts[module.host], st.presence({ from = module.host, to = host, id = stanza.attr.id, type = "subscribed" }));
-		core_post_stanza(hosts[module.host], st.presence({ from = module.host, to = host, id = stanza.attr.id }));
+		module:send(st.presence({ from = module.host, to = host, id = stanza.attr.id, type = "subscribed" }));
+		module:send(st.presence({ from = module.host, to = host, id = stanza.attr.id }));
 		add_contact(host);
 	elseif t == "subscribed" then
 		subscription_to[host] = true;
 		query_host(host);
 	elseif t == "unsubscribe" then
 		subscription_from[host] = nil;
-		core_post_stanza(hosts[module.host], st.presence({ from = module.host, to = host, id = stanza.attr.id, type = "unsubscribed" }));
+		module:send(st.presence({ from = module.host, to = host, id = stanza.attr.id, type = "unsubscribed" }));
 		remove_contact(host);
 	elseif t == "unsubscribed" then
 		subscription_to[host] = nil;
@@ -64,16 +63,16 @@
 	contact_vcards[host] = nil;
 	if subscription_to[host] then
 		subscription_to[host] = nil;
-		core_post_stanza(hosts[module.host], st.presence({ from = module.host, to = host, id = id, type = "unsubscribe" }));
+		module:send(st.presence({ from = module.host, to = host, id = id, type = "unsubscribe" }));
 	end
 	if subscription_from[host] then
 		subscription_from[host] = nil;
-		core_post_stanza(hosts[module.host], st.presence({ from = module.host, to = host, id = id, type = "unsubscribed" }));
+		module:send(st.presence({ from = module.host, to = host, id = id, type = "unsubscribed" }));
 	end
 end
 function add_contact(host, id)
 	if not subscription_to[host] then
-		core_post_stanza(hosts[module.host], st.presence({ from = module.host, to = host, id = id, type = "subscribe" }));
+		module:send(st.presence({ from = module.host, to = host, id = id, type = "subscribe" }));
 	end
 end
 
@@ -110,7 +109,7 @@
 function query_host(host)
 	local stanza = st.iq({ from = module.host, to = host, type = "get", id = "mod_service_directories:disco" })
 		:query("http://jabber.org/protocol/disco#info");
-	core_post_stanza(hosts[module.host], stanza);
+	module:send(stanza);
 end
 
 -- Handle disco query result
@@ -135,7 +134,7 @@
 	if features["urn:ietf:params:xml:ns:vcard-4.0"] then
 		local stanza = st.iq({ from = module.host, to = host, type = "get", id = "mod_service_directories:vcard" })
 			:tag("vcard", { xmlns = "urn:ietf:params:xml:ns:vcard-4.0" });
-		core_post_stanza(hosts[module.host], stanza);
+		module:send(stanza);
 	end
 	return true;
 end);