Software /
code /
prosody
Changeset
753:3a0f9cf38f99
tools/ejabberd2prosody: Support for pending-in roster items
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Thu, 29 Jan 2009 22:37:25 +0500 |
parents | 738:cf70342985df |
children | 754:01abf314fac0 |
files | tools/ejabberd2prosody.lua |
diffstat | 1 files changed, 17 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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