Comparison

plugins/mod_vcard.lua @ 549:c0947c0af398

Changed the datastore for vCards from vCard to vcard in mod_vcard and mod_register
author Waqas Hussain <waqas20@gmail.com>
date Fri, 05 Dec 2008 00:16:03 +0500
parent 541:3521e0851c9e
child 615:4ae3e81513f3
comparison
equal deleted inserted replaced
547:265c4b8f0a8a 549:c0947c0af398
37 if stanza.attr.type == "get" then 37 if stanza.attr.type == "get" then
38 local vCard; 38 local vCard;
39 if to then 39 if to then
40 local node, host = jid_split(to); 40 local node, host = jid_split(to);
41 if hosts[host] and hosts[host].type == "local" then 41 if hosts[host] and hosts[host].type == "local" then
42 vCard = st.deserialize(datamanager.load(node, host, "vCard")); -- load vCard for user or server 42 vCard = st.deserialize(datamanager.load(node, host, "vcard")); -- load vCard for user or server
43 end 43 end
44 else 44 else
45 vCard = st.deserialize(datamanager.load(session.username, session.host, "vCard"));-- load user's own vCard 45 vCard = st.deserialize(datamanager.load(session.username, session.host, "vcard"));-- load user's own vCard
46 end 46 end
47 if vCard then 47 if vCard then
48 session.send(st.reply(stanza):add_child(vCard)); -- send vCard! 48 session.send(st.reply(stanza):add_child(vCard)); -- send vCard!
49 else 49 else
50 session.send(st.error_reply(stanza, "cancel", "item-not-found")); 50 session.send(st.error_reply(stanza, "cancel", "item-not-found"));
51 end 51 end
52 elseif stanza.attr.type == "set" then 52 elseif stanza.attr.type == "set" then
53 if not to or to == session.username.."@"..session.host then 53 if not to or to == session.username.."@"..session.host then
54 if datamanager.store(session.username, session.host, "vCard", st.preserialize(stanza.tags[1])) then 54 if datamanager.store(session.username, session.host, "vcard", st.preserialize(stanza.tags[1])) then
55 session.send(st.reply(stanza)); 55 session.send(st.reply(stanza));
56 else 56 else
57 -- TODO unable to write file, file may be locked, etc, what's the correct error? 57 -- TODO unable to write file, file may be locked, etc, what's the correct error?
58 session.send(st.error_reply(stanza, "wait", "internal-server-error")); 58 session.send(st.error_reply(stanza, "wait", "internal-server-error"));
59 end 59 end
64 return true; 64 return true;
65 end 65 end
66 end); 66 end);
67 67
68 local feature_vcard_attr = { var='vcard-temp' }; 68 local feature_vcard_attr = { var='vcard-temp' };
69 module:add_event_hook("stream-features", 69 module:add_event_hook("stream-features",
70 function (session, features) 70 function (session, features)
71 if session.type == "c2s" then 71 if session.type == "c2s" then
72 features:tag("feature", feature_vcard_attr):up(); 72 features:tag("feature", feature_vcard_attr):up();
73 end 73 end
74 end); 74 end);