Comparison

plugins/mod_vcard.lua @ 2001:2f73fe2b3edd

mod_vcard: Moved completely to new event based hooks.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 18 Oct 2009 07:05:56 +0500
parent 2000:c31aa53348b8
child 2002:fa71261d8a15
comparison
equal deleted inserted replaced
2000:c31aa53348b8 2001:2f73fe2b3edd
19 19
20 local xmlns_vcard = "vcard-temp"; 20 local xmlns_vcard = "vcard-temp";
21 21
22 module:add_feature(xmlns_vcard); 22 module:add_feature(xmlns_vcard);
23 23
24 function handle_vcard(session, stanza) 24 function handle_vcard(event)
25 local session, stanza = event.origin, event.stanza;
25 if stanza.tags[1].name == "vCard" then 26 if stanza.tags[1].name == "vCard" then
26 local to = stanza.attr.to; 27 local to = stanza.attr.to;
27 if stanza.attr.type == "get" then 28 if stanza.attr.type == "get" then
28 local vCard; 29 local vCard;
29 if to then 30 if to then
53 end 54 end
54 return true; 55 return true;
55 end 56 end
56 end 57 end
57 58
58 module:add_iq_handler({"c2s", "s2sin", "component"}, xmlns_vcard, handle_vcard); 59 --module:add_iq_handler({"c2s", "s2sin", "component"}, xmlns_vcard, handle_vcard);
60 module:hook("iq/bare/vcard-temp:vCard", handle_vcard);
61 module:hook("iq/host/vcard-temp:vCard", handle_vcard);
59 62
60 -- COMPAT: https://support.process-one.net/browse/EJAB-1045 63 -- COMPAT: https://support.process-one.net/browse/EJAB-1045
61 if module:get_option("vcard_compatibility") then 64 if module:get_option("vcard_compatibility") then
62 module:hook("iq/full", function (data) 65 module:hook("iq/full", function (data)
63 local stanza = data.stanza; 66 local stanza = data.stanza;
64 if stanza.attr.type == "get" and stanza.tags[1] 67 if stanza.attr.type == "get" and stanza.tags[1]
65 and stanza.tags[1].attr.xmlns == xmlns_vcard then 68 and stanza.tags[1].attr.xmlns == xmlns_vcard then
66 return handle_vcard(data.origin, stanza); 69 return handle_vcard(data);
67 end 70 end
68 end, 1); 71 end, 1);
69 end 72 end
70 73
71 local feature_vcard_attr = { var=xmlns_vcard }; 74 local feature_vcard_attr = { var=xmlns_vcard };