Software /
code /
prosody
Changeset
754:01abf314fac0
Automated merge with http://waqas.ath.cx:8000/
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 29 Jan 2009 17:54:37 +0000 |
parents | 753:3a0f9cf38f99 (diff) 752:a9642c1d5827 (current diff) |
children | 755:c9f4f7f08a48 |
files | |
diffstat | 1 files changed, 17 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/tools/ejabberd2prosody.lua Thu Jan 29 02:14:16 2009 +0000 +++ b/tools/ejabberd2prosody.lua Thu Jan 29 17:54:37 2009 +0000 @@ -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