aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-01-29 22:37:25 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-01-29 22:37:25 +0500
commit8fc233d7f5e6a5bee04d6b26a761ac2f9f88e57d (patch)
tree746d58bf3ab60df185c203591e034daa0a7bc3e7
parent5da8d030772c430bafef92bab6fa3d43767695b2 (diff)
downloadprosody-8fc233d7f5e6a5bee04d6b26a761ac2f9f88e57d.tar.gz
prosody-8fc233d7f5e6a5bee04d6b26a761ac2f9f88e57d.zip
tools/ejabberd2prosody: Support for pending-in roster items
-rwxr-xr-xtools/ejabberd2prosody.lua24
1 files changed, 17 insertions, 7 deletions
diff --git a/tools/ejabberd2prosody.lua b/tools/ejabberd2prosody.lua
index 2f837497..c2034715 100755
--- a/tools/ejabberd2prosody.lua
+++ b/tools/ejabberd2prosody.lua
@@ -57,12 +57,19 @@ function password(node, host, password)
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 filters = {
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