Software /
code /
prosody
Comparison
plugins/mod_vcard_legacy.lua @ 9809:5648e8733569 0.11
mod_vcard_legacy: Adapt node defaults to number of avatars
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 11 Jan 2019 09:20:48 +0100 |
parent | 9808:00d210deea28 |
child | 9810:2d8e2de36654 |
comparison
equal
deleted
inserted
replaced
9808:00d210deea28 | 9809:5648e8733569 |
---|---|
252 | 252 |
253 if pep_service:purge("urn:xmpp:avatar:metadata", actor) then | 253 if pep_service:purge("urn:xmpp:avatar:metadata", actor) then |
254 pep_service:purge("urn:xmpp:avatar:data", actor); | 254 pep_service:purge("urn:xmpp:avatar:data", actor); |
255 end | 255 end |
256 | 256 |
257 local avatar_defaults = node_defaults; | |
258 if #avatars > 1 then | |
259 avatar_defaults = {}; | |
260 for k,v in pairs(node_defaults) do | |
261 avatar_defaults[k] = v; | |
262 end | |
263 avatar_defaults.max_items = #avatars; | |
264 end | |
257 for _, avatar in ipairs(avatars) do | 265 for _, avatar in ipairs(avatars) do |
258 local ok, err = pep_service:publish("urn:xmpp:avatar:data", actor, avatar.hash, avatar.data, node_defaults) | 266 local ok, err = pep_service:publish("urn:xmpp:avatar:data", actor, avatar.hash, avatar.data, avatar_defaults) |
259 if ok then | 267 if ok then |
260 ok, err = pep_service:publish("urn:xmpp:avatar:metadata", actor, avatar.hash, avatar.meta, node_defaults); | 268 ok, err = pep_service:publish("urn:xmpp:avatar:metadata", actor, avatar.hash, avatar.meta, avatar_defaults); |
261 end | 269 end |
262 if not ok then | 270 if not ok then |
263 return ok, err; | 271 return ok, err; |
264 end | 272 end |
265 end | 273 end |