Comparison

tools/ejabberdsql2prosody.lua @ 1596:4fcb2df97141

ejabberdsql2prosody: Fixed: pending-in subscriptions could halt processing
author Waqas Hussain <waqas20@gmail.com>
date Sun, 26 Jul 2009 15:28:04 +0500
parent 1595:9551055b5344
child 1597:84328a4df655
comparison
equal deleted inserted replaced
1595:9551055b5344 1596:4fcb2df97141
193 function roster_pending(node, host, jid) 193 function roster_pending(node, host, jid)
194 local roster = dm.load(node, host, "roster") or {}; 194 local roster = dm.load(node, host, "roster") or {};
195 roster.pending = roster.pending or {}; 195 roster.pending = roster.pending or {};
196 roster.pending[jid] = true; 196 roster.pending[jid] = true;
197 local ret, err = dm.store(node, host, "roster", roster); 197 local ret, err = dm.store(node, host, "roster", roster);
198 print("["..(err or "success").."] roster: " ..node.."@"..host.." - "..jid); 198 print("["..(err or "success").."] roster-pending: " ..node.."@"..host.." - "..jid);
199 end 199 end
200 function roster_group(node, host, jid, group) 200 function roster_group(node, host, jid, group)
201 local roster = dm.load(node, host, "roster") or {}; 201 local roster = dm.load(node, host, "roster") or {};
202 local item = roster[jid]; 202 local item = roster[jid];
203 if not item then print("Warning: No roster item "..jid.." for user "..user..", can't put in group "..group); return; end 203 if not item then print("Warning: No roster item "..jid.." for user "..user..", can't put in group "..group); return; end
204 item.groups[group] = true; 204 item.groups[group] = true;
205 local ret, err = dm.store(node, host, "roster", roster); 205 local ret, err = dm.store(node, host, "roster", roster);
206 print("["..(err or "success").."] roster: " ..node.."@"..host.." - "..jid); 206 print("["..(err or "success").."] roster-group: " ..node.."@"..host.." - "..jid.." - "..group);
207 end 207 end
208 for i, row in ipairs(t["rosterusers"] or NULL) do 208 for i, row in ipairs(t["rosterusers"] or NULL) do
209 local node, contact = row.username, row.jid; 209 local node, contact = row.username, row.jid;
210 local name = row.nick; 210 local name = row.nick;
211 if name == "" then name = nil; end 211 if name == "" then name = nil; end
224 ask = nil; 224 ask = nil;
225 elseif ask == "O" then 225 elseif ask == "O" then
226 ask = "subscribe"; 226 ask = "subscribe";
227 elseif ask == "I" then 227 elseif ask == "I" then
228 roster_pending(node, host, contact); 228 roster_pending(node, host, contact);
229 return;
230 else error("Unknown ask type: "..ask); end 229 else error("Unknown ask type: "..ask); end
231 local item = {name = name, ask = ask, subscription = subscription, groups = {}}; 230 local item = {name = name, ask = ask, subscription = subscription, groups = {}};
232 roster(node, host, contact, item); 231 roster(node, host, contact, item);
233 end 232 end
234 for i, row in ipairs(t["rostergroups"] or NULL) do 233 for i, row in ipairs(t["rostergroups"] or NULL) do