Changeset

3268:4cdd1ddae72c

mod_auto_answer_disco_info: Simplify iq handling by hooking on the full payload tag instead of iq/full.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 24 Aug 2018 20:55:10 +0200
parents 3267:4b43b317e8f5
children 3269:b0628bc93acf
files mod_auto_answer_disco_info/mod_auto_answer_disco_info.lua
diffstat 1 files changed, 3 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mod_auto_answer_disco_info/mod_auto_answer_disco_info.lua	Fri Aug 24 20:49:54 2018 +0200
+++ b/mod_auto_answer_disco_info/mod_auto_answer_disco_info.lua	Fri Aug 24 20:55:10 2018 +0200
@@ -2,15 +2,9 @@
 
 local st = require "util.stanza";
 
-local function iq_stanza_handler(event)
+local function disco_handler(event)
 	local stanza, origin = event.stanza, event.origin;
-	local type = stanza.attr.type;
-
-	local query = stanza:get_child("query", "http://jabber.org/protocol/disco#info");
-	if type ~= "get" or query == nil then
-		return;
-	end
-
+	local query = stanza.tags[1];
 	local to = stanza.attr.to;
 	local node = query.attr.node;
 
@@ -30,4 +24,4 @@
 	end
 end
 
-module:hook("iq/full", iq_stanza_handler, 1);
+module:hook("iq-get/full/http://jabber.org/protocol/disco#info:query", disco_handler, 1);