Software /
code /
prosody
Diff
core/rostermanager.lua @ 177:606c433955e7
Bug fixes and checks for presence subscriptions, etc
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 26 Oct 2008 00:22:18 +0500 |
parent | 176:e5cd2a03891d |
child | 183:403db3b5c3c2 |
line wrap: on
line diff
--- a/core/rostermanager.lua Sat Oct 25 21:16:08 2008 +0500 +++ b/core/rostermanager.lua Sun Oct 26 00:22:18 2008 +0500 @@ -49,7 +49,7 @@ end function roster_push(username, host, jid) - if hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster then + if jid ~= "pending" and hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster then local item = hosts[host].sessions[username].roster[jid]; local stanza = st.iq({type="set"}); stanza:tag("query", {xmlns = "jabber:iq:roster"}); @@ -74,19 +74,23 @@ end function load_roster(username, host) + log("debug", "load_roster: asked for: "..username.."@"..host); if hosts[host] and hosts[host].sessions[username] then local roster = hosts[host].sessions[username].roster; if not roster then + log("debug", "load_roster: loading for new user: "..username.."@"..host); roster = datamanager.load(username, host, "roster") or {}; hosts[host].sessions[username].roster = roster; end return roster; end -- Attempt to load roster for non-loaded user + log("debug", "load_roster: loading for offline user: "..username.."@"..host); return datamanager.load(username, host, "roster") or {}; end function save_roster(username, host) + log("debug", "save_roster: saving roster for "..username.."@"..host); if hosts[host] and hosts[host].sessions[username] and hosts[host].sessions[username].roster then return datamanager.store(username, host, "roster", hosts[host].sessions[username].roster); end @@ -159,7 +163,7 @@ function is_contact_pending_in(username, host, jid) local roster = load_roster(username, host); - return roster.pending or roster.pending[jid]; + return roster.pending and roster.pending[jid]; end function set_contact_pending_in(username, host, jid, pending) local roster = load_roster(username, host); @@ -183,10 +187,11 @@ return true; end if not item then - item = {subscription = "none"}; + item = {subscription = "none", groups = {}}; roster[jid] = item; end item.ask = "subscribe"; + log("debug", "set_contact_pending_out: saving roster; set "..username.."@"..host..".roster["..jid.."].ask=subscribe"); return datamanager.store(username, host, "roster", roster); end function unsubscribe(username, host, jid) @@ -211,7 +216,7 @@ if item.subscription == "none" then item.subscription = "from"; else -- subscription == to - item.subsctiption = "both"; + item.subscription = "both"; end roster.pending[jid] = nil; -- TODO maybe remove roster.pending if empty