Comparison

plugins/mod_pep.lua @ 5682:e7b9ba2d0638

mod_pep: When a client supplies no id on a published item, reflect our generated id back to it
author Florian Zeitz <florob@babelmonkeys.de>
date Thu, 13 Jun 2013 13:56:35 +0100
parent 5170:3eaf4fc58902
child 5683:624b874059bf
child 5804:bb27ba619932
comparison
equal deleted inserted replaced
5680:24b044f6e06d 5682:e7b9ba2d0638
60 user_data[node] = nil; 60 user_data[node] = nil;
61 if not next(user_data) then data[bare] = nil; end 61 if not next(user_data) then data[bare] = nil; end
62 end 62 end
63 else 63 else
64 if not user_data then user_data = {}; data[bare] = user_data; end 64 if not user_data then user_data = {}; data[bare] = user_data; end
65 user_data[node] = {id or "1", item}; 65 user_data[node] = {id, item};
66 end 66 end
67 67
68 -- broadcast 68 -- broadcast
69 for recipient, notify in pairs(recipients[bare] or NULL) do 69 for recipient, notify in pairs(recipients[bare] or NULL) do
70 if notify[node] then 70 if notify[node] then
167 payload = payload.tags[1]; 167 payload = payload.tags[1];
168 if payload and (payload.name == 'publish' or payload.name == 'retract') and payload.attr.node then -- <publish node='http://jabber.org/protocol/tune'> 168 if payload and (payload.name == 'publish' or payload.name == 'retract') and payload.attr.node then -- <publish node='http://jabber.org/protocol/tune'>
169 local node = payload.attr.node; 169 local node = payload.attr.node;
170 payload = payload.tags[1]; 170 payload = payload.tags[1];
171 if payload and payload.name == "item" then -- <item> 171 if payload and payload.name == "item" then -- <item>
172 local id = payload.attr.id; 172 local id = payload.attr.id or "1";
173 payload.attr.id = id;
173 session.send(st.reply(stanza)); 174 session.send(st.reply(stanza));
174 publish(session, node, id, st.clone(payload)); 175 publish(session, node, id, st.clone(payload));
175 return true; 176 return true;
176 end 177 end
177 end 178 end