comparison mod_profile/mod_profile.lua @ 2413:b64c0150d663

mod_profile: Add warning and debug logging in order to catch a weird event
author Kim Alvefur <zash@zash.se>
date Sat, 03 Dec 2016 23:18:53 +0100
parents 851cb0b3d584
children 5163f7905371
comparison
equal deleted inserted replaced
2412:9159f9166893 2413:b64c0150d663
141 module:hook("iq-set/host/vcard-temp:vCard", handle_set); 141 module:hook("iq-set/host/vcard-temp:vCard", handle_set);
142 142
143 local function on_publish(event) 143 local function on_publish(event)
144 if event.actor == true then return end -- Not from a client 144 if event.actor == true then return end -- Not from a client
145 local node, item = event.node, event.item; 145 local node, item = event.node, event.item;
146 local username = jid_split(event.actor); 146 local username, host = jid_split(event.actor);
147 if host ~= module.host then
148 module:log("warn", "on_publish() called for non-local actor");
149 for k,v in pairs(event) do
150 module:log("debug", "event[%q] = %q", tosting(k), tostring(v));
151 end
152 return;
153 end
147 local data = storage:get(username) or {}; 154 local data = storage:get(username) or {};
148 if node == "urn:xmpp:avatar:data" then 155 if node == "urn:xmpp:avatar:data" then
149 local new_photo = item:get_child_text("data", "urn:xmpp:avatar:data"); 156 local new_photo = item:get_child_text("data", "urn:xmpp:avatar:data");
150 new_photo = new_photo and { name = "PHOTO"; ENCODING = { "b" }; new_photo } or nil; 157 new_photo = new_photo and { name = "PHOTO"; ENCODING = { "b" }; new_photo } or nil;
151 local _, i = get_item(data, "PHOTO") 158 local _, i = get_item(data, "PHOTO")