Software /
code /
prosody
Comparison
plugins/mod_iq.lua @ 3656:71fd1582f01b
mod_iq: Extra IQ get and set sub-events are now fired: "iq-{get,set}/{host,self,bare}/xmlns:tag" (when "iq/{host,self,bare}/xmlns:tag" is unhandled).
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 28 Nov 2010 02:24:26 +0500 |
parent | 3647:140ce81778ca |
child | 3657:07f0c2ef16cb |
comparison
equal
deleted
inserted
replaced
3655:9a590b03a8d6 | 3656:71fd1582f01b |
---|---|
33 -- IQ to bare JID recieved | 33 -- IQ to bare JID recieved |
34 local origin, stanza = data.origin, data.stanza; | 34 local origin, stanza = data.origin, data.stanza; |
35 | 35 |
36 -- TODO fire post processing events | 36 -- TODO fire post processing events |
37 if stanza.attr.type == "get" or stanza.attr.type == "set" then | 37 if stanza.attr.type == "get" or stanza.attr.type == "set" then |
38 return module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); | 38 local ret = module:fire_event("iq/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); |
39 if ret ~= nil then return ret; end | |
40 return module:fire_event("iq-"..stanza.attr.type.."/bare/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); | |
39 else | 41 else |
40 module:fire_event("iq-"..stanza.attr.type.."/bare/"..stanza.attr.id, data); | 42 module:fire_event("iq-"..stanza.attr.type.."/bare/"..stanza.attr.id, data); |
41 return true; | 43 return true; |
42 end | 44 end |
43 end); | 45 end); |
44 | 46 |
45 module:hook("iq/self", function(data) | 47 module:hook("iq/self", function(data) |
46 -- IQ to bare JID recieved | 48 -- IQ to self JID recieved |
47 local origin, stanza = data.origin, data.stanza; | 49 local origin, stanza = data.origin, data.stanza; |
48 | 50 |
49 if stanza.attr.type == "get" or stanza.attr.type == "set" then | 51 if stanza.attr.type == "get" or stanza.attr.type == "set" then |
50 return module:fire_event("iq/self/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); | 52 local ret = module:fire_event("iq/self/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); |
53 if ret ~= nil then return ret; end | |
54 return module:fire_event("iq-"..stanza.attr.type.."/self/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); | |
51 else | 55 else |
52 module:fire_event("iq-"..stanza.attr.type.."/self/"..stanza.attr.id, data); | 56 module:fire_event("iq-"..stanza.attr.type.."/self/"..stanza.attr.id, data); |
53 return true; | 57 return true; |
54 end | 58 end |
55 end); | 59 end); |
57 module:hook("iq/host", function(data) | 61 module:hook("iq/host", function(data) |
58 -- IQ to a local host recieved | 62 -- IQ to a local host recieved |
59 local origin, stanza = data.origin, data.stanza; | 63 local origin, stanza = data.origin, data.stanza; |
60 | 64 |
61 if stanza.attr.type == "get" or stanza.attr.type == "set" then | 65 if stanza.attr.type == "get" or stanza.attr.type == "set" then |
62 return module:fire_event("iq/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); | 66 local ret = module:fire_event("iq/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); |
67 if ret ~= nil then return ret; end | |
68 return module:fire_event("iq-"..stanza.attr.type.."/host/"..stanza.tags[1].attr.xmlns..":"..stanza.tags[1].name, data); | |
63 else | 69 else |
64 module:fire_event("iq-"..stanza.attr.type.."/host/"..stanza.attr.id, data); | 70 module:fire_event("iq-"..stanza.attr.type.."/host/"..stanza.attr.id, data); |
65 return true; | 71 return true; |
66 end | 72 end |
67 end); | 73 end); |