Software /
code /
prosody
Comparison
tools/ejabberd2prosody.lua @ 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 |
parent | 643:8ff454831f7d |
child | 758:b1885732e979 |
comparison
equal
deleted
inserted
replaced
738:cf70342985df | 753:3a0f9cf38f99 |
---|---|
61 local roster = dm.load(node, host, "roster") or {}; | 61 local roster = dm.load(node, host, "roster") or {}; |
62 roster[jid] = item; | 62 roster[jid] = item; |
63 local ret, err = dm.store(node, host, "roster", roster); | 63 local ret, err = dm.store(node, host, "roster", roster); |
64 print("["..(err or "success").."] roster: " ..node.."@"..host.." - "..jid); | 64 print("["..(err or "success").."] roster: " ..node.."@"..host.." - "..jid); |
65 end | 65 end |
66 function roster_pending(node, host, jid) | |
67 local roster = dm.load(node, host, "roster") or {}; | |
68 roster.pending = roster.pending or {}; | |
69 roster.pending[jid] = true; | |
70 local ret, err = dm.store(node, host, "roster", roster); | |
71 print("["..(err or "success").."] roster: " ..node.."@"..host.." - "..jid); | |
72 end | |
66 function private_storage(node, host, xmlns, stanza) | 73 function private_storage(node, host, xmlns, stanza) |
67 local private = dm.load(node, host, "private") or {}; | 74 local private = dm.load(node, host, "private") or {}; |
68 private[xmlns] = st.preserialize(stanza); | 75 private[xmlns] = st.preserialize(stanza); |
69 local ret, err = dm.store(node, host, "private", private); | 76 local ret, err = dm.store(node, host, "private", private); |
70 print("["..(err or "success").."] private: " ..node.."@"..host.." - "..xmlns); | 77 print("["..(err or "success").."] private: " ..node.."@"..host.." - "..xmlns); |
88 local node = tuple[3][1]; local host = tuple[3][2]; | 95 local node = tuple[3][1]; local host = tuple[3][2]; |
89 local contact = (type(tuple[4][1]) == "table") and tuple[4][2] or tuple[4][1].."@"..tuple[4][2]; | 96 local contact = (type(tuple[4][1]) == "table") and tuple[4][2] or tuple[4][1].."@"..tuple[4][2]; |
90 local name = tuple[5]; local subscription = tuple[6]; | 97 local name = tuple[5]; local subscription = tuple[6]; |
91 local ask = tuple[7]; local groups = tuple[8]; | 98 local ask = tuple[7]; local groups = tuple[8]; |
92 if type(name) ~= type("") then name = nil; end | 99 if type(name) ~= type("") then name = nil; end |
93 if ask == "none" then ask = nil; elseif ask == "out" then ask = "subscribe" else error(ask) end | 100 if ask == "none" then ask = nil; elseif ask == "out" then ask = "subscribe" elseif ask == "in" then |
101 roster_pending(node, host, contact); | |
102 return; | |
103 else error(ask) end | |
94 if subscription ~= "both" and subscription ~= "from" and subscription ~= "to" and subscription ~= "none" then error(subscription) end | 104 if subscription ~= "both" and subscription ~= "from" and subscription ~= "to" and subscription ~= "none" then error(subscription) end |
95 local item = {name = name, ask = ask, subscription = subscription, groups = {}}; | 105 local item = {name = name, ask = ask, subscription = subscription, groups = {}}; |
96 for _, g in ipairs(groups) do item.groups[g] = true; end | 106 for _, g in ipairs(groups) do item.groups[g] = true; end |
97 roster(node, host, contact, item); | 107 roster(node, host, contact, item); |
98 end; | 108 end; |