Comparison

plugins/mod_vcard_legacy.lua @ 9518:a62fa766d8f3

mod_vcard_legacy: Create nodes with open access (fixes #1221) Less drastic change from mod_vcard where everything is always public. This allows users to configure nodes without needing to for the old behaviour. Thanks to 038446c50630 users may still override this. Due to #1222 this may still not apply if the node has already been created by an automatic subscription
author Kim Alvefur <zash@zash.se>
date Thu, 18 Oct 2018 19:07:01 +0200
parent 9286:992e986589b8
child 9520:d6964d16455c
comparison
equal deleted inserted replaced
9517:b1c6ede17592 9518:a62fa766d8f3
136 136
137 origin.send(st.reply(stanza):add_child(vcard_temp)); 137 origin.send(st.reply(stanza):add_child(vcard_temp));
138 return true; 138 return true;
139 end); 139 end);
140 140
141 local node_defaults = {
142 access_model = "open";
143 _defaults_only = true;
144 };
145
141 module:hook("iq-set/self/vcard-temp:vCard", function (event) 146 module:hook("iq-set/self/vcard-temp:vCard", function (event)
142 local origin, stanza = event.origin, event.stanza; 147 local origin, stanza = event.origin, event.stanza;
143 local pep_service = mod_pep.get_pep_service(origin.username); 148 local pep_service = mod_pep.get_pep_service(origin.username);
144 149
145 local vcard_temp = stanza.tags[1]; 150 local vcard_temp = stanza.tags[1];
147 local vcard4 = st.stanza("item", { xmlns = "http://jabber.org/protocol/pubsub", id = "current" }) 152 local vcard4 = st.stanza("item", { xmlns = "http://jabber.org/protocol/pubsub", id = "current" })
148 :tag("vcard", { xmlns = 'urn:ietf:params:xml:ns:vcard-4.0' }); 153 :tag("vcard", { xmlns = 'urn:ietf:params:xml:ns:vcard-4.0' });
149 154
150 if pep_service:purge("urn:xmpp:avatar:metadata", origin.full_jid) then 155 if pep_service:purge("urn:xmpp:avatar:metadata", origin.full_jid) then
151 pep_service:purge("urn:xmpp:avatar:data", origin.full_jid); 156 pep_service:purge("urn:xmpp:avatar:data", origin.full_jid);
152 end 157 else
158 pep_service:create("urn:xmpp:avatar:metadata", origin.full_jid, node_defaults);
159 pep_service:create("urn:xmpp:avatar:data", origin.full_jid, node_defaults);
160 end
161
162 pep_service:create("urn:xmpp:vcard4", origin.full_jid, node_defaults);
153 163
154 vcard4:tag("fn"):text_tag("text", vcard_temp:get_child_text("FN")):up(); 164 vcard4:tag("fn"):text_tag("text", vcard_temp:get_child_text("FN")):up();
155 165
156 local N = vcard_temp:get_child("N"); 166 local N = vcard_temp:get_child("N");
157 167