Mercurial > prosody-modules
comparison mod_auto_answer_disco_info/mod_auto_answer_disco_info.lua @ 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 | 1fe7da46e915 |
children | 05c74210c007 |
comparison
equal
deleted
inserted
replaced
3267:4b43b317e8f5 | 3268:4cdd1ddae72c |
---|---|
1 module:depends("cache_c2s_caps"); | 1 module:depends("cache_c2s_caps"); |
2 | 2 |
3 local st = require "util.stanza"; | 3 local st = require "util.stanza"; |
4 | 4 |
5 local function iq_stanza_handler(event) | 5 local function disco_handler(event) |
6 local stanza, origin = event.stanza, event.origin; | 6 local stanza, origin = event.stanza, event.origin; |
7 local type = stanza.attr.type; | 7 local query = stanza.tags[1]; |
8 | |
9 local query = stanza:get_child("query", "http://jabber.org/protocol/disco#info"); | |
10 if type ~= "get" or query == nil then | |
11 return; | |
12 end | |
13 | |
14 local to = stanza.attr.to; | 8 local to = stanza.attr.to; |
15 local node = query.attr.node; | 9 local node = query.attr.node; |
16 | 10 |
17 local target_session = prosody.full_sessions[to]; | 11 local target_session = prosody.full_sessions[to]; |
18 if target_session == nil then | 12 if target_session == nil then |
28 module:send(iq); | 22 module:send(iq); |
29 return true; | 23 return true; |
30 end | 24 end |
31 end | 25 end |
32 | 26 |
33 module:hook("iq/full", iq_stanza_handler, 1); | 27 module:hook("iq-get/full/http://jabber.org/protocol/disco#info:query", disco_handler, 1); |