# HG changeset patch # User Waqas Hussain # Date 1224774150 -18000 # Node ID 9a4aa57af367aa888387a1e6ed83e37f7559678c # Parent 4bbbc7883ee6af790c9e469cb6f586db6a662bb4 Roster updates - Added support for item.ask attribute in rostermanager and mod_roster - Updated roster docs - Removed old code from rostermanager diff -r 4bbbc7883ee6 -r 9a4aa57af367 core/rostermanager.lua --- a/core/rostermanager.lua Thu Oct 23 19:53:02 2008 +0500 +++ b/core/rostermanager.lua Thu Oct 23 20:02:30 2008 +0500 @@ -18,17 +18,6 @@ module "rostermanager" ---[[function getroster(username, host) - return { - ["mattj@localhost"] = true, - ["tobias@getjabber.ath.cx"] = true, - ["waqas@getjabber.ath.cx"] = true, - ["thorns@getjabber.ath.cx"] = true, - ["idw@getjabber.ath.cx"] = true, - } - --return datamanager.load(username, host, "roster") or {}; -end]] - function add_to_roster(session, jid, item) if session.roster then local old_item = session.roster[jid]; @@ -65,7 +54,7 @@ local stanza = st.iq({type="set"}); stanza:tag("query", {xmlns = "jabber:iq:roster"}); if item then - stanza:tag("item", {jid = jid, subscription = item.subscription, name = item.name}); + stanza:tag("item", {jid = jid, subscription = item.subscription, name = item.name, ask = item.ask}); for group in pairs(item.groups) do stanza:tag("group"):text(group):up(); end @@ -94,6 +83,7 @@ return roster; end -- Attempt to load roster for non-loaded user + -- TODO also support loading for offline user end function save_roster(username, host) diff -r 4bbbc7883ee6 -r 9a4aa57af367 doc/roster_format.txt --- a/doc/roster_format.txt Thu Oct 23 19:53:02 2008 +0500 +++ b/doc/roster_format.txt Thu Oct 23 20:02:30 2008 +0500 @@ -9,7 +9,7 @@ string subscription = "none" | "to" | "from" | "both" string name = Opaque string set by client. (optional) set groups = a set of opaque strings set by the client - boolean ask = nil | true - a value of true indicates subscription is pending + boolean ask = nil | "subscribe" - a value of true indicates subscription is pending } The roster is available as diff -r 4bbbc7883ee6 -r 9a4aa57af367 plugins/mod_roster.lua --- a/plugins/mod_roster.lua Thu Oct 23 19:53:02 2008 +0500 +++ b/plugins/mod_roster.lua Thu Oct 23 20:02:30 2008 +0500 @@ -19,6 +19,7 @@ roster:tag("item", { jid = jid, subscription = session.roster[jid].subscription, + ask = session.roster[jid].ask, name = session.roster[jid].name, }); for group in pairs(session.roster[jid].groups) do @@ -54,6 +55,7 @@ if r_item.name == "" then r_item.name = nil; end if session.roster[item.attr.jid] then r_item.subscription = session.roster[item.attr.jid].subscription; + r_item.ask = session.roster[item.attr.jid].ask; else r_item.subscription = "none"; end