# HG changeset patch # User Waqas Hussain # Date 1233250645 -18000 # Node ID 3a0f9cf38f9954308fb13342daf937b1a642ca23 # Parent cf70342985dfffda936dcbf7bb52b3f4e9bc9efc tools/ejabberd2prosody: Support for pending-in roster items diff -r cf70342985df -r 3a0f9cf38f99 tools/ejabberd2prosody.lua --- a/tools/ejabberd2prosody.lua Fri Jan 16 23:34:45 2009 +0000 +++ b/tools/ejabberd2prosody.lua Thu Jan 29 22:37:25 2009 +0500 @@ -57,12 +57,19 @@ local ret, err = dm.store(node, host, "accounts", {password = password}); print("["..(err or "success").."] accounts: "..node.."@"..host.." = "..password); end -function roster(node, host, jid, item) - local roster = dm.load(node, host, "roster") or {}; - roster[jid] = item; - local ret, err = dm.store(node, host, "roster", roster); - print("["..(err or "success").."] roster: " ..node.."@"..host.." - "..jid); -end +function roster(node, host, jid, item) + local roster = dm.load(node, host, "roster") or {}; + roster[jid] = item; + local ret, err = dm.store(node, host, "roster", roster); + print("["..(err or "success").."] roster: " ..node.."@"..host.." - "..jid); +end +function roster_pending(node, host, jid) + local roster = dm.load(node, host, "roster") or {}; + roster.pending = roster.pending or {}; + roster.pending[jid] = true; + local ret, err = dm.store(node, host, "roster", roster); + print("["..(err or "success").."] roster: " ..node.."@"..host.." - "..jid); +end function private_storage(node, host, xmlns, stanza) local private = dm.load(node, host, "private") or {}; private[xmlns] = st.preserialize(stanza); @@ -90,7 +97,10 @@ local name = tuple[5]; local subscription = tuple[6]; local ask = tuple[7]; local groups = tuple[8]; if type(name) ~= type("") then name = nil; end - if ask == "none" then ask = nil; elseif ask == "out" then ask = "subscribe" else error(ask) end + if ask == "none" then ask = nil; elseif ask == "out" then ask = "subscribe" elseif ask == "in" then + roster_pending(node, host, contact); + return; + else error(ask) end if subscription ~= "both" and subscription ~= "from" and subscription ~= "to" and subscription ~= "none" then error(subscription) end local item = {name = name, ask = ask, subscription = subscription, groups = {}}; for _, g in ipairs(groups) do item.groups[g] = true; end